fix: onParserTimeout potentially accessing undefined #4758
+7
−2
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