Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does a node.js process suddenly die on osx with no explanation in any log file?

90% of the time I always get a stack trace. But sometimes the process just quits and I have no idea why. Anyway to print the stack trace always? Or find more information in dmesg or something?

like image 813
Andrew Arrow Avatar asked Apr 03 '13 19:04

Andrew Arrow


1 Answers

okay finally found a way to find the error:

node --trace app.js

it outputs every function call and I can see the stacktrace right before it exits with:

startup.processKillAndExit.process.exit

And my stacktrace points to:

redis.get('bar', (err, data) -> JSON.parse(value).foo)

JSON.parse(value) comes back null so .foo throws:

[TypeError: Cannot read property 'foo' of null]

and for some reason the TypeError inside a redis callback is swallowed and causes node to exit without printing the error.

like image 180
Andrew Arrow Avatar answered Sep 20 '22 06:09

Andrew Arrow