Skip to content

Conversation

@vbfox
Copy link

@vbfox vbfox commented Jan 22, 2026

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:

Cannot destructure property 'socket' of 'parser.deref(...)' as it is
undefined

As specified in the issue as I couldn't find a way to trigger it without a time mock framework replacing clearTimeout with 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

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
Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

Can you add a test for it?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.23%. Comparing base (761fce9) to head (80b75cf).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
lib/dispatcher/client-h1.js 71.42% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Cannot destructure property 'socket' of 'parser.deref(...)' as it is undefined.

4 participants