-
Notifications
You must be signed in to change notification settings - Fork 50.9k
[Flight] Fix visitAsyncNode infinite recursion with circular async nodes #35246
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
Closed
jere-co
wants to merge
2
commits into
facebook:main
from
jere-co:fix/visitAsyncNode-infinite-recursion
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR description you write:
However, this doesn't actually fix the reported issue. I've synced your fix to the repro app and it still runs into a stack overflow. The fix just appears to work because it's not applied correctly here:
https://github.com/jere-co/next-debug/blob/25c992b4e021765343067a30d8b70fa20a337448/patch-visitAsyncNode.cjs#L128
That patch returns
undefinedinstead ofnull. If we did that, we'd drop I/O info for valid cases, which you can see with the failing unit tests that this change would trigger.Also, I think the
IN_PROGRESSsentinel as implemented here doesn't actually change the cycle detection behavior. The original code already returnsnullfor a cycle (viavisited.get(node)returning thenullthat was set before recursing). The sentinel would only matter if we wanted to return something different on cycle detection.It seems like the DB library is producing very long linear chains of async nodes via
previouspointers, and the stack overflow comes from the recursive traversal of these chains, not from undetected cycles. A proper fix might require converting thepreviouschain traversal from recursive to iterative, though this gets complicated because the traversal also needs to handleawaitedbranches and return values need to propagate correctly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this maybe: #35612