Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useless stacktraces when using require in generator #4286

Closed
faiwer opened this issue Dec 15, 2015 · 1 comment
Closed

Useless stacktraces when using require in generator #4286

faiwer opened this issue Dec 15, 2015 · 1 comment
Labels
module Issues and PRs related to the module subsystem.

Comments

@faiwer
Copy link

faiwer commented Dec 15, 2015

Content of test.js:

(function()
{
    "use strict";

    function * gen()
    {
        try { require('./bad.js'); }
        catch(e)
        {
            console.log(e.message);
            console.log(e.stack);
        }
    }

    gen().next();
})();

Content of bad.js:

bad syntax

Stack trace:

Unexpected identifier
SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at gen (/tmp/gen/test.js:7:9)
    at next (native)
    at /tmp/gen/test.js:15:8

No data about linenumber and filename. Only "Unexpected identifier".

node --version
v5.0.0
@mscdex mscdex added the lib / src Issues and PRs related to general changes in the lib or src directory. label Dec 15, 2015
@mscdex
Copy link
Contributor

mscdex commented Dec 15, 2015

This actually isn't specific to generator functions. Errors coming from vm are typically not decorated with the "arrow message." FWIW I've submitted #4287 that always adds that extra information to require() errors.

@mscdex mscdex added module Issues and PRs related to the module subsystem. and removed lib / src Issues and PRs related to general changes in the lib or src directory. labels Dec 15, 2015
@mscdex mscdex closed this as completed in 18490d3 Dec 19, 2015
Fishrock123 pushed a commit to Fishrock123/node that referenced this issue Dec 22, 2015
This provides more information when encountering a syntax or similar
error when executing a file with require().

Fixes: nodejs#4286
PR-URL: nodejs#4287
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
scovetta pushed a commit to scovetta/node that referenced this issue Apr 2, 2016
This provides more information when encountering a syntax or similar
error when executing a file with require().

Fixes: nodejs#4286
PR-URL: nodejs#4287
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants