How to fix a stack overflow error on a large document?

Hello everyone,
I receive the following message, when creating a quite big document (about 500 pages including a lot of images):
> Typst Compile shows the following error:
*> *
> thread ‘main’ has overflowed its stack
Is there anything I can do about this?
Thank you and best regards,
Benjamin

Hey @Benjamin_Reck, I’ve updated your post title to a question per our guidelines at How to post in the Questions category (please take a look!).

Can you let us know which platform and editor are you using? For example, if you’re using the web app, can you try compiling your document locally instead, using either the Typst CLI (Releases · typst/typst · GitHub) or the tinymist extension in e.g. VSCode or your favorite editor? Thanks!

Hey @PgBiel ,
thanks a lot for your quick feedback.
I use the Typst CLI from last March to compile my code, but also the most current version has the same issue.
I am using Windows 11 Pro, maybe that information helps as well.
Please let me know if you nee dfurther information.
Best

I see. Given your document’s size, it’s possible the compiler is simply running out of available memory. Although Windows is particularly known for having less stack memory specifically, which could also separately lead to this error. Regardless, I would check memory usage in your System Monitor or Task Manager during compilation to check if that could be the cause.

In either case, the main solution I can think of is providing more memory, perhaps by using a different machine to compile (could be one in the cloud).

Just a guess from my side.
Try to comment out (not compile) the last 5 or 7 chapters and see what happens. If it does compile, add one chapter and compile again. Repeat the process until you get Stack Overflow error. Check the chapter you added the latest chapter for potential issues.