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?

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.

2 participants