Skip to content
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

Correctly invoke async router callback asynchronously #4891

Closed
wants to merge 3 commits into from

Conversation

lqqyt2423
Copy link

Sometimes this error occurs:
RangeError: Maximum call stack size exceeded

This pull request can fix the error.

Copy link
Contributor

@dougwilson dougwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please add a test case or leave in the pr a demo of the issue and we can make it in to a test case.

@lqqyt2423
Copy link
Author

@dougwilson Please see the new commit

@dougwilson dougwilson mentioned this pull request Apr 13, 2022
20 tasks
@dougwilson
Copy link
Contributor

Great, thank you! Would you be willing to open the same PR over at https://github.com/pillarjs/router ?

@@ -203,6 +204,12 @@ proto.handle = function handle(req, res, out) {
return;
}

// max sync stack
if (++sync > 100) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without looking at the current v8 stack frames, there is no way to know if you still have 100 frames left to use. Also params will add/remove to how many frames are used in each iteration, I wouldn't think. How did you come up with the number 100 for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dougwilson dougwilson changed the base branch from master to 4.18 April 14, 2022 03:13
@lqqyt2423
Copy link
Author

@dougwilson router repo already fixed it: pillarjs/router@e96ebf5

I have a new commit to fix stack overflow with a large sync stack: 538a789

@dougwilson
Copy link
Contributor

Ah, I guess we didn't port that over, lol! Thanks for pointing that out. I'll port that commit over to 4.18 🎉

@dougwilson dougwilson closed this Apr 14, 2022
dougwilson added a commit that referenced this pull request Apr 14, 2022
@expressjs expressjs deleted a comment from nicokaiser May 20, 2022
@expressjs expressjs locked as resolved and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants