-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maximum call stack size exceeded on waitAll(long_list_of_simple_tasks). #227
Comments
Any workaround/idea that could help me circumvent this issue will also be appreciated! Thanks! |
This happens because all of your tasks are synchronous, and JS VMs don't deal well with recursion. The work-around involves pretty much managing the stack so it doesn't fill up. So, for example, you can make all of the tasks asynchronous, in which case all of them will start on an empty stack when they run:
But this has performance implications, and it's not always as straight-forward to do. In the general usage, Tasks mostly contain asynchronous computations, where this isn't as much of a problem, but these edge-cases can be pretty frustrating. Ideally Folktale would solve this (e.g.: running tasks in a stack-safe manner, at the expense of some performance), but I haven't had the time to work on it lately, so I'm not sure when/if this will be fixed. |
Hey @robotlolita thanks for getting back to me and taking the time to give a very useful response. I don't mind them being async, what I actually need to do is a "fire and forget" type of thing, my only problem is that I tried running your snippet and it gave me the exact same error. Could you take a look at it again? |
I've a long list of simple tasks (30k of them) and I'd like to be able to wait for all of them and it fails with a
Maximum call stack size exceeded
errorSteps to reproduce
If you run this program:
Expected behaviour
It should return a list of consecutive numbers from 1 to 29999
Observed behaviour
Yet, I get this error:
Environment
(Describe the environment where the problem happens. This usually includes:
)
The text was updated successfully, but these errors were encountered: