-
Notifications
You must be signed in to change notification settings - Fork 623
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
Calling async function recursively stops (randomly?) after 126 calls #1055
Comments
This is not a random number, it seems you are running into the native stack limit error. You can read more about the details here #135 (comment) However, at a first glance of this code, I'm not sure why this is recursing on the native stack. |
@fbmal7 thanks for your quick answer. But why is it running on the native stack? I'm not using any native functions here. Also, why am I not getting a RangerError for this case? |
Not sure yet what's going on, but this does look like a bug.
The print statement for 'after' is executed after 126 is printed out, which definitely is wrong. Thanks for raising this. |
@fbmal7 if I run the example with JSC, I get:
But again no error. |
@SharonBrizinov what command did you run to get your "Expected Output"? If I run the code with
Indicating that the error causing the nonzero exit code is for unhandled Promise rejection, not actually for stack overflow. Hermes does have a mechanism for setting up unhandled Promise rejection tracking, but it's not enabled by default on the CLI tool (much like JSC, based on tmikov's comment above). https://github.com/facebook/hermes/blob/main/lib/VM/JSLib/HermesInternal.cpp#L697 explains how to set up Promise rejection tracking: one can use the |
Thanks @avp! so the only question remains is why it's using the native stack for this case? |
Internally, async functions compile to uses of generators, and the generator |
Interesting, thanks @avp |
FWIW, the limit will increase when we deploy native stack checking. The current limit is deliberately very conservative, to avoid the possibility of native stack overflow. |
Bug Description
I was playing with async function in Hermes and found something strange - when calling an async function recursively it will execute 126 times while in fact it should run forever, until exhausting the call stack.
Version
Hermes version: v0.12.0 and latest main branch commit 36195b3
OS version (if any): Ubutnu v22.04
Steps To Reproduce
Run the following code snippet
Current output
The Expected Behavior
run until exhausting the call stack at approx ~80654 recursive calls
The text was updated successfully, but these errors were encountered: