Thanks for tagging me @Maxwell, I would have missed this otherwise! I think I will also need an MWE, though.
Does this still happen if you remove a previous chapter (e.g., in your loop, add if nth == 3 { continue })? Or, is there a warning that layout did not converge in addition to the error? If it doesn’t, or if there is, it’s not actually (immediately) Alexandria.
Unfortunately, Alexandria uses almost all the iteration budget that Typst gives: bibliographies are first configured, then citations are collected, then the bibliography is created by Alexandria, and finally the citations are actually rendered. Using the heading counter to contextually determine the prefix adds another iteration, and that may be too much. Maybe there’s also something else going on that adds an iteration?
The iteration before the one that actually succeeds doesn’t have the correct bibliography yet, so the citations fail. Normally you don’t see that, but when the iterations run out, the errors of that iteration are visible, even though they’re not the root of the problem.