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.

A little bit confused by timeoutId

See original GitHub issue
this.timers[timeoutId] = timeoutId

actually setTimeout return an object in Node.js so the key in this.timers is ‘[object object]’ so it will be override every time so the timer always hold only one child

maybe not works as you expected?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mpvossellercommented, Jun 11, 2021

I noticed this bug and was going to suggest a combination of Date.now() and Math.random()

timeoutId = `${Date.now()}${Math.random()}` // '16234269777330.8934721663218723'

However, I wasn’t able to actually reproduce the bug in Node. Turns out in Nonde v14.9.0 and v12.19.0 they added a method to the Timeout object [Symbol.toPrimitive] which converts it to a number. As such it now “just works” and a compatible number is used as the key.

Unless you want to support older versions of Node I think you can close this.

0reactions
jessetanecommented, Jun 11, 2021

Thanks for the note! Closing for now then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scheduling: setTimeout and setInterval
Nested setTimeout allows to set the delay between the executions more precisely than setInterval . Let's compare two code fragments. The first ...
Read more >
Confused with set timeout - Stack Overflow
I'm really confused how these work...the timeout does not seem to keep running it calls begin_anim once and then thats it.
Read more >
Query on system settings : r/QRadar - Reddit
I am little bit confused with these TCP options. ... Timeout for Idle TCP Syslog Connections (seconds) : What is this ?
Read more >
setTimeout JavaScript Function: Guide with Examples - SitePoint
To demonstrate the concept in more detail, the following demo displays a popup, ... const timeoutID = setTimeout(code); const timeoutID ...
Read more >
JavaScript Timers with setTimeout and setInterval
setTimeout() allows you to specify that a piece of JavaScript code (called ... where expression is the JavaScript code to run after timeout...
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