It happens without longjohn, too.
I don't exactly know why, but if you name your callbacks, it works better:
setTimeout(function MyFirstTimeoutCallback() {
throw new Error();
}, 10);
...
This generates the following traceback:
/private/tmp/node_modules/longjohn/dist/longjohn.js:181
throw e;
^
Error
at MyFirstTimeoutCallback (/private/tmp/lj.js:4:9) <-- much better!
at listOnTimeout (timers.js:110:15)
---------------------------------------------
at Object.<anonymous> (/private/tmp/lj.js:3:1)
at Module._compile (module.js:456:26)
at Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Module._load (module.js:312:12)
at Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
EDIT: looks like this bug was introduced (somewhere) in Node 0.10. When I test with 0.8.23, it looks okay:
timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
Error
at Object.<anonymous> (/private/tmp/lj.js:4:9) <-- correct
at list.ontimeout (timers.js:101:19)
...
(bug report)
EDIT #2: it's a confirmed bug in V8 (see the linked bug report).
To know more about Node JS, It's recommended to join Node JS Online Course today.