TypeError: setTimeout(...).unref is not a function
See original GitHub issueHi! I have some problems with using stoppable on node v8.7.0
here are couple of stack traces:
TypeError: setTimeout(...).unref is not a function
at Immediate.setImmediate [as _onImmediate] (node_modules/stoppable/lib/stoppable.js:33:39)
at runCallback (timers.js:785:20)
at tryOnImmediate (timers.js:747:5)
at processImmediate [as _immediateCallback] (timers.js:718:5)
TypeError: setTimeout(...).unref is not a function
at Immediate.setImmediate [as _onImmediate] (node_modules/stoppable/lib/stoppable.js:33:39)
at runCallback (timers.js:785:20)
at tryOnImmediate (timers.js:747:5)
at processImmediate (timers.js:718:5)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
I use babel, jest, flow and lots of other things, so it’s hard to say is it problem of stoppable or not.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
TypeError: setTimeout(...).unref is not a function
in your jest.config.js , make sure there's this: module.exports = { testEnvironment: 'node', };. See more about this option on the ...
Read more >Calling Timeout.unref() With setTimeout() Does Not Appear ...
This tells Node. js to exit out of the process (in this demo) if the timeout is the only pending operation.
Read more >Timer Mocks
The native timer functions (i.e., setTimeout(), setInterval(), ... At this point in time, the callback should not have been called yet
Read more >Process | Node.js v18 API
The listener callback function is invoked with the value of process. ... If the parameter passed in is not a tuple Array ,...
Read more >Node.js – Timeout-ref() & Timeout-unref() method
timeout.unref(). This method will tell the timeout object that the Node.js event loop does not need to be active anymore. If there is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve seen things like this happen when run from Jest, which runs in Browser-mode by default, which means it replaces setTimeout and does not return an object with an
unref
function on it. Perhaps you’re also running in some sort of browser emulation mode?Could the call to
unref
be replaced by a call toclearTimeout
in theserver.close
callback?The point of
unref
is that it lets the Node process terminate if it’s the only remaining thing. But that process isn’t going to terminate until the server is closed (unless you’ve also unreffed the server, I guess?), so the first time it could possibly be relevant is after theserver.close
callback is done. So we might as well just call clearTimeout ourselves at that point, no?