fix: onParserTimeout potentially accessing undefined#4758
Merged
mcollina merged 1 commit intonodejs:mainfrom Feb 1, 2026
Merged
fix: onParserTimeout potentially accessing undefined#4758mcollina merged 1 commit intonodejs:mainfrom
mcollina merged 1 commit intonodejs:mainfrom
Conversation
In cases where onParserTimeout is called with a weak reference that has
already been collected it was throwing an error like:
Cannot destructure property 'socket' of 'parser.deref(...)' as it is
undefined
- Fixes nodejs#4755
metcoder95
reviewed
Jan 23, 2026
Member
metcoder95
left a comment
There was a problem hiding this comment.
Can you add a test for it?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4758 +/- ##
=======================================
Coverage 93.22% 93.23%
=======================================
Files 109 109
Lines 34024 34029 +5
=======================================
+ Hits 31720 31726 +6
+ Misses 2304 2303 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merged
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
In cases where onParserTimeout is called with a weak reference that has
already been collected it was throwing an error like:
Cannot destructure property 'socket' of 'parser.deref(...)' as it is
undefined
- Fixes nodejs#4755
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This relates to...
Rationale
In cases where onParserTimeout is called with a weak reference that has
already been collected it was throwing an error like:
As specified in the issue as I couldn't find a way to trigger it without a time mock framework replacing
clearTimeoutwith a NOP so i'm not sure it qualifies as a bug.(And also why I didn't include tests, but it should be triggerable by manually changing the global
clearTimeout)It's more akin to a potential type error (In an untyped language 😉) but I feel that checking for undefined here would make for a bit better code, and make it resistant against mocking of the global timers.
Fell free to close the PR and issue if it's considered too trivial or risky.
Changes
Features
N/A
Bug Fixes
N/A
Breaking Changes and Deprecations
Status