Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for existence of unref before calling #13

Merged
merged 1 commit into from Nov 8, 2021

Conversation

ewanharris
Copy link
Contributor

Environments like Electron do not always expose the Node.js setTiemout, so there is no unref
function on resTimeout. So update the check to also check if the unref function exists

Ref: electron/electron#21162

@isaacs
Copy link
Contributor

isaacs commented Jun 29, 2021

Sounds good to me. Needs a test that fails without the patch and passes with it, though.

@ewanharris
Copy link
Contributor Author

ewanharris commented Jun 29, 2021

I've added a test that overrides setTimeout to emulate running in environments that don't have unref. I'm not super familiar with tap so I'm not sure how to ensure that setTimeout gets reset if the test throws. Please let me know if you think there's a better way to have the test mock that behaviour

@settings settings bot removed the needs test label Sep 21, 2021
Environments like Electron do not always expose the Node.js setTiemout,
so there is no unref function on resTimeout. So update the check to also
check if the unref function exists

Ref: electron/electron#21162

PR-URL: npm#13
Credit: @ewanharris
Close: npm#13
Reviewed-by: @isaacs
@isaacs isaacs closed this in 05fb45b Nov 8, 2021
@isaacs isaacs merged commit 05fb45b into npm:main Nov 8, 2021
@isaacs
Copy link
Contributor

isaacs commented Nov 8, 2021

Thanks! I tweaked the test a little to put the reset into a t.teardown() method, since that'll get called even if the test fails.

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.

None yet

2 participants