-
Notifications
You must be signed in to change notification settings - Fork 563
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
fix: refactor fast timers, fix UND_ERR_CONNECT_TIMEOUT on event loop blocking #3495
Conversation
cf4ca88
to
ea4e9e8
Compare
d87f441
to
ac7a6e0
Compare
ac7a6e0
to
a36e184
Compare
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.
This is a huge PR... not sure I have time to review properly in forseeable future.
This is a big issue over at Vercel, know it's a big PR but it's also quite important for lots of people :) |
There are simpler PRs that solve the issue. I think the problem here is that we are combining a significant refactoring with bug fixes. |
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.
LGTM
can you run the benchmark before/after to see if this impacted us at all?
After a quick skim it seems fine, and all tests are passing. If it introduces some regresisons, then I'm pretty sure some users of Next.js/Vercel would report this quickly find out. |
I'm +-0 |
I want to add a small explaination of this refactoring. I wanted to modify the fasttimer implementation. Yes it is kind of simple while you are implementing it and everything makes sense. But when working on it the first time, it is kind of hard to grok. So I started to comment the code and e.g. also replace the magic numbers with constants, and renamed the atrtibutes to be more expressive. While I was investigating how the native timers are structured, I realized I should use their data structure/naming of the attributes. Thats why I renamed e.g. delay with _idleTimeout or callback with _onTimeout. Also I tried to rename variables. when a different name was making more sense. E.g. in client-h1.js So in my opinion to review the timers.js file the first step is to just read the comments and check if it matches with the code it describes. And if it is good commented you should have a good idea on how the fast timers actually work. The rest should be then easy to review. |
IMHO all the comments and explanations make it harder to grasp and read. But if everyone else is happy with it I won't block. Good job. |
Could you maybe summarize what behavior changes this introduces? |
Of course. I will in about 30 min, when i am back from groceries shopping ;) |
Well, I was looking into the code while writing what changes I implemented. I made a coverage check and realized, that the changes in client-h1.js seem to be not covered by a unit test. So I am currently implementing a unit test for that, just as a sanity check. |
I reverted the changes regarding timeoutDeadline in client-h1,js as those changes are not covered by a unit test. As soon as I find a test case and those lines fix the test then I would add them back. |
Is there a chance to push out the Vercel-related errror fix first (so the most urgent) and then open a separate PR for everything else? |
dd96443
to
33fe101
Compare
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.
lgtm
Should this be backported to 6.x? A backport was requested in follow-up PR, but it failed because of merge conflicts #3552 (comment) |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-v6.x v6.x
# Navigate to the new working tree
cd .worktrees/backport-v6.x
# Create a new branch
git switch --create backport-3495-to-v6.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8a09d77037024b80e4efc6df53bf8cd1d36b14eb
# Push it to GitHub
git push --set-upstream origin backport-3495-to-v6.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-v6.x Then, create a pull request where the |
The backport fails to 6.x, as reducing memory usage in client-h1 from #3510 is not backported. |
…blocking (#3495) (#3673) * fix: refactor fast timers, fix UND_ERR_CONNECT_TIMEOUT on event loop blocking * also test native timers * improve the commentary of fasttimers * revert changes in client-h1.js * make fasttimers independent from performance.now * less flaky? (cherry picked from commit 8a09d77) Co-authored-by: Aras Abbasi <[email protected]>
@trivikr if you want to open a Pr to backport those commits down, please be our guest! |
I followed the instructions posted by the bot in #3495 (comment), and then found out backporting failed as the previous PR wasn't backported. I thus posted #3495 (comment) to inform maintainers to take appropriate actions. I'll provide console output in future, so that there's clarification about the comment. |
You're welcome! And thank you for adding labels to the PRs in appropriate order.
Yup. And then we can release new undici version (say https://github.com/nodejs/undici/releases/tag/v6.20.0) and merge it before next Node.js release (is it https://github.com/nodejs/node/releases/tag/v22.10.0)? |
superseeds #3494
superseeds #3418
fixes #3493
fixes #3410
Date.now()
- ensuring that changes of the system clock wont effect the timerstimers.js
exports anow
method to retrieve the value of the internal clockBased on the work of @ronag i refactored the fast timers and hopefully fixed also the connection timeout bug when the event loop is blocked.