krasimir / absurd

A JavaScript library with superpowers
http://absurdjs.krasimirtsonev.com/
MIT License
1.38k stars 90 forks source link

process.on('uncaughtException') breaks the environment #124

Closed aaronabramov closed 9 years ago

aaronabramov commented 9 years ago

hey. i noticed these lines inside index.js https://github.com/krasimir/absurd/blob/master/index.js#L22-L24

process.on('uncaughtException', function (err) {
    console.log("Error packing", err);
});

Which will break any project that requires this library.

e.g. the code

// /tmp/test_error.js
process.on('uncaughtException', function (err) {
    console.log("Error packing", err);
});

throw new Error('Error');

will produce useless message:

>  node error_test.js
Error packing [Error: Error]

instead of what node provides by default (including stack trace and all that):

/tmp/error_test.js:1
(function (exports, require, module, __filename, __dirname) { throw new Error(
                                                                    ^
Error: Error
    at Object.<anonymous> (/tmp/error_test.js:1:69)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

is there way to get rid of it? and how is it used?

krasimir commented 9 years ago

@dmitriiabramov thank you for spotting this. It's fixed here. There is a new version 0.3.5 released. The reason behind this is that Absurd may be used as a CLI program and there is a watching mode. In this case we want to keep the process running and only report that there is an error. What I did is simply running that logic only if Absurd is run from the terminal.

aaronabramov commented 9 years ago

@krasimir thanks for fixing it so quickly!

krasimir commented 9 years ago

You are welcome :)