GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: use fasttimers for all connection timeouts by Uzlopak · Pull Request #3552 · nodejs/undici

Conversation

@Uzlopak

@Uzlopak Uzlopak commented Sep 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #3410
Fixes #3553

currently WIP!

Assessment:

The PR #3495 was imho the right step to fix the event loop issues. But Connection issues were still reported. Maybe the issue still existing because timeouts smaller than 1000ms will be handled by native Timers. Maybe those have to handled by the low resolution fast timer logic too, so that event loop blockers are less effecting the processing of requests.

Maybe we should increase the resolution of the timers to 200ms?! It should be still more performant than having a gazillion of native timers?

Maybe we should change this else if to an if and maybe check if the timer missed a tick (with the side effect that we need to call performance.now()).

undici/lib/util/timers.js

Line 159 in 89a46dd

} else if (

So if we skipped a tick, we immediatly run the timer, because we are just too late?

But on the other hand, this could actually trigger timeouts too early?!

So yeah, I would prefer to increase the resolution.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Uzlopak
Uzlopak force-pushed the fast-timer-connect branch from abc40ac to 4922c97 Compare September 5, 2024 01:57
@KhafraDev

KhafraDev commented Sep 5, 2024

Copy link
Copy Markdown
Member

Are the fast timers even needed anymore after nodejs/node#46579?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag

ronag commented Sep 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Yea. I don't think that PR (nodejs/node#46579) makes much difference.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag

ronag commented Sep 5, 2024

Copy link
Copy Markdown
Member

Are the fast timers even needed anymore after nodejs/node#46579?

Fast timers also adjust for event loop lag.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak

Uzlopak commented Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

Ok, then i change this PR to rip out fast timers

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak
Uzlopak force-pushed the fast-timer-connect branch from 4922c97 to 5dcfaaa Compare September 5, 2024 06:17
@Uzlopak Uzlopak changed the title fix: use fasttimers for all connection timeouts fix: remove fast timers implementation Sep 5, 2024
@Uzlopak
Uzlopak requested review from KhafraDev and ronag September 5, 2024 06:19
ronag
ronag requested changes Sep 5, 2024
View reviewed changes

@ronag ronag left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Do not remove fast timers. That's the opposite of what I was trying to say.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Uzlopak
fix: use fasttimers for all connection timeouts
7393ea3
@Uzlopak
Uzlopak force-pushed the fast-timer-connect branch from 5dcfaaa to 7393ea3 Compare September 5, 2024 06:47
@Uzlopak

Uzlopak commented Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

@ronag

Oh! good that i had a backup :). reverted

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak Uzlopak changed the title fix: remove fast timers implementation fix: use fasttimers for all connection timeouts Sep 5, 2024
Uzlopak
Uzlopak commented Sep 5, 2024
View reviewed changes
Comment thread lib/util/timers.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak
Apply suggestions from code review
391d336
ronag
ronag approved these changes Sep 5, 2024
View reviewed changes
@Uzlopak

Uzlopak commented Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

@ronag

but one thing maybe for interest

The test run for ripped out fast timers passes the tests

https://github.com/nodejs/undici/actions/runs/10714949877

This indicates that event loop lags are also handled properly by native timers.

But I guess we want to keep our fast timers solution due to the fact, that it is still less resource hungry.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag

ronag commented Sep 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This indicates that event loop lags are also handled properly by native timers.

IMO This shouldn't be true as it's based on the uv loop... to me it more indicates an issue with our test

metcoder95 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

metcoder95
metcoder95 approved these changes Sep 5, 2024
View reviewed changes
@Uzlopak

Uzlopak commented Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

let me fix the request-timeout tests.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak

Uzlopak commented Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

@ronag

Should we also use setFastTimeout here?

undici/lib/core/connect.js

Line 169 in 61a4b69

const timer = timers.setTimeout(() => {

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag

ronag commented Sep 5, 2024

Copy link
Copy Markdown
Member

Yes

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Uzlopak added 2 commits September 5, 2024 14:34
@Uzlopak
activate some tests
5a2d9db
@Uzlopak
also use fastTimers in connect.js
70d4d9f
@Uzlopak

Uzlopak commented Sep 5, 2024

Copy link
Copy Markdown
Contributor Author

adapted so far, but not all tests are reactivated. so please not merge yet

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak Uzlopak mentioned this pull request Sep 5, 2024
fix: use native timeouts for TIMEOUT_IDLE, rename TIMEOUT_IDLE to TIMEOUT_KEEP_ALIVE #3554
Merged
Uzlopak added 3 commits September 6, 2024 00:06
@Uzlopak
fix tests
bb05bd8
@Uzlopak
fix tests
875cbdd
@Uzlopak
fix tests
77f7337
Uzlopak added 2 commits September 6, 2024 13:13
@Uzlopak
ignore request-timeout binary file, rename clearAll to reset
454070e
@Uzlopak
fix
5316009
ronag
ronag reviewed Sep 6, 2024
View reviewed changes
Comment thread lib/core/connect.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronag
ronag reviewed Sep 6, 2024
View reviewed changes
Comment thread lib/core/connect.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Uzlopak added 3 commits September 6, 2024 13:46
@Uzlopak
add test
387a750
@Uzlopak
use queueMicrotask earlier in the socket callbacks
75ddb34
@Uzlopak
Merge branch 'main' into fast-timer-connect
1fd5f93
@Uzlopak

Uzlopak commented Sep 8, 2024

Copy link
Copy Markdown
Contributor Author

@ronag

Because you asked, why i change the port. The thing is, that I want to use the port for the connection timeout to have in the logs the chance to determine atleast which server/connection resulted in a connection timeout.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ronag
ronag approved these changes Sep 8, 2024
View reviewed changes
@ronag
ronag merged commit dca0aa0 into main Sep 8, 2024
@Uzlopak
Uzlopak deleted the fast-timer-connect branch September 8, 2024 16:32
@metcoder95 metcoder95 added the backport v6.x label Sep 12, 2024
@github-actions

github-actions Bot commented Sep 12, 2024

Copy link
Copy Markdown
Contributor

The backport to v6.x failed:

The process '/usr/bin/git' failed with exit code 1

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-3552-to-v6.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 dca0aa0998cbdef28916b23d6300beb2fd979140
# Push it to GitHub
git push --set-upstream origin backport-3552-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 base branch is v6.x and the compare/head branch is backport-3552-to-v6.x.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trivikr

trivikr commented Oct 2, 2024

Copy link
Copy Markdown
Member

The backport fails to 6.x, as the refactor of fast timers in #3495 is not backported to 6.x

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trivikr trivikr mentioned this pull request Oct 2, 2024
fix: refactor fast timers, fix UND_ERR_CONNECT_TIMEOUT on event loop blocking #3495
Merged
@Uzlopak Uzlopak added backport v6.x and removed backport v6.x labels Oct 4, 2024
@github-actions

github-actions Bot commented Oct 4, 2024

Copy link
Copy Markdown
Contributor

The backport to v6.x failed:

The process '/usr/bin/git' failed with exit code 1

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-3552-to-v6.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 dca0aa0998cbdef28916b23d6300beb2fd979140
# Push it to GitHub
git push --set-upstream origin backport-3552-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 base branch is v6.x and the compare/head branch is backport-3552-to-v6.x.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak Uzlopak added backport v6.x and removed backport v6.x labels Oct 4, 2024
github-actions Bot pushed a commit that referenced this pull request Oct 4, 2024
@Uzlopak @github-actions
fix: use fasttimers for all connection timeouts (#3552)
1ac565b
* fix: use fasttimers for all connection timeouts

* Apply suggestions from code review

* activate some tests

* also use fastTimers in connect.js

* fix tests

* fix tests

* fix tests

* fix: use native timeouts for TIMEOUT_IDLE, rename TIMEOUT_IDLE to TIMEOUT_KEEP_ALIVE (#3554)

* fix: use native timeouts for TIMEOUT_IDLE, rename TIMEOUT_IDLE to TIMEOUT_KEEP_ALIVE

* ensure that fast timers and native timers are set properly

* .

* .

* rename import

* more informative connection error

* ignore request-timeout binary file, rename clearAll to reset

* fix

* add test

* use queueMicrotask earlier in the socket callbacks

(cherry picked from commit dca0aa0)
@github-actions github-actions Bot mentioned this pull request Oct 4, 2024
[Backport v6.x] fix: use fasttimers for all connection timeouts #3675
Merged
mcollina pushed a commit that referenced this pull request Oct 4, 2024
@github-actions @Uzlopak
fix: use fasttimers for all connection timeouts (#3552) (#3675)
d047e99
* fix: use fasttimers for all connection timeouts

* Apply suggestions from code review

* activate some tests

* also use fastTimers in connect.js

* fix tests

* fix tests

* fix tests

* fix: use native timeouts for TIMEOUT_IDLE, rename TIMEOUT_IDLE to TIMEOUT_KEEP_ALIVE (#3554)

* fix: use native timeouts for TIMEOUT_IDLE, rename TIMEOUT_IDLE to TIMEOUT_KEEP_ALIVE

* ensure that fast timers and native timers are set properly

* .

* .

* rename import

* more informative connection error

* ignore request-timeout binary file, rename clearAll to reset

* fix

* add test

* use queueMicrotask earlier in the socket callbacks

(cherry picked from commit dca0aa0)

Co-authored-by: Aras Abbasi <[email protected]>
@github-actions github-actions Bot mentioned this pull request Dec 3, 2024
[Release] v7.1.0 #3922
Merged
This was referenced Dec 16, 2024
[Release] v7.1.1 #3952
Closed
[Release] v7.2.0 #3962
Merged
@github-actions github-actions Bot mentioned this pull request Mar 12, 2025
[Release] v6.21.2 #4092
Closed
@github-actions github-actions Bot mentioned this pull request May 12, 2025
[Release] v6.21.3 #4211
Closed
@elastic-renovate-prod elastic-renovate-prod Bot mentioned this pull request May 21, 2025
Update dependency undici-types to v7 elastic/llm-debug-proxy#8
Open
1 task
@Israel-Kli Israel-Kli mentioned this pull request Nov 18, 2026
docs: correct parser timeout precision note #6224
Open
3 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ronag ronag ronag approved these changes
@metcoder95 metcoder95 metcoder95 approved these changes
@KhafraDev KhafraDev Awaiting requested review from KhafraDev

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backport v6.x

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

TIMEOUT_IDLE should include event loop lag UND_ERR_CONNECT_TIMEOUT errors thrown when there is CPU intensive code on the event loop

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Uzlopak @KhafraDev @ronag @trivikr @metcoder95
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.