Skip to content

C stack overflow when using await in a loop #1499

@dogagithub

Description

@dogagithub

Hello,

I've encountered a "C stack overflow" error while running the following TypeScript code which gets transpiled to Lua using TypeScriptToLua:
for (let i = 0; i < 40; i++) { await delay(0.1); print('times:', i); }
The function delay is an asynchronous function that returns a Promise that resolves after the specified delay. The print function logs the current iteration to the console.

The issue occurs when the loop reaches the 36th iteration (i=35), at which point the program crashes with a "C stack overflow" error. The expected behavior would be for the loop to successfully complete all 40 iterations without any issues.

I've tried debugging the issue on my end but haven't been able to find a workaround. I've also ensured that the issue is not due to any memory leaks, high CPU usage, or problems with the delay function or the Lua runtime.

I'm using TypeScriptToLua version 1.20.1 and running the resulting Lua code in environment Warcraft III

Any help on this issue would be greatly appreciated.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions