question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'unref' of undefined

See original GitHub issue

I’m getting this error in node.js during the cleanup while the program is shutting down. I can narrow down the problem to these two lines of code:

https://github.com/feross/simple-peer/blob/master/index.js#L876

self._interval = setInterval(function () { self._onInterval() }, 150)
if (self._interval.unref) self._interval.unref()

It seems that in Node the return value of setInterval can sometimes be undefined, perhaps during some post-event-loop cleanup or something like that. I think the second line here should be changed to

if (self._interval && self._interval.unref) self._interval.unref()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
lackercommented, Jun 21, 2019
0reactions
nazar-pccommented, Jun 21, 2019

Can you report to jsdom developers that this is wrong and breaks applications, please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnhandledPromiseRejectionWar...
(node:5088) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'close' of undefined at Object.<anonymous> (C:\Users\Olakunle-PC\ ...
Read more >
Resolving the JavaScript Promise Error "TypeError: Cannot ...
TypeError - Cannot read property 'then' of undefined is thrown when the caller is expecting a Promise to be returned and instead receives ......
Read more >
TypeError: Cannot read property 'data' of undefined
to show where the warning was created) [0] (node:24430) UnhandledPromiseRejectionWarning: Unhandled promise rejection.
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
TypeError: Cannot read property 'startsWith' of undefined
TypeError : Cannot read property 'startsWith' of undefined: D:\codespace\zzz\node_modules\mongodb-connection-string-url\lib\index.js:9 return ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found