callsite-record icon indicating copy to clipboard operation
callsite-record copied to clipboard

Error: ENOENT: no such file or directory, open 'path.js'

Open vjpr opened this issue 9 years ago • 6 comments

Error: ENOENT: no such file or directory, open 'path.js'
    at Error (native)
    at Object.fs.openSync (fs.js:634:18)
    at Object.fs.readFileSync (fs.js:502:33)
    at CallsiteRecord.renderSync (/Users/Vaughan/dev-live/shipmate/node_modules/callsite-record/lib/index.js:205:26)
    at StackFormater._formater (/Users/Vaughan/dev-live/shipmate/lib/stack-format/index.js:58:40)

renderSync should handle the case where the file cannot be found...e.g. that it is a node.js internal.

CallsiteRecord.prototype.renderSync = function (opts) {
    var fileContent = fs.readFileSync(this.filename).toString();

    return this._renderRecord(fileContent, opts);
};

vjpr avatar Jun 02 '16 06:06 vjpr

Nice find, thanks!

inikulin avatar Jun 02 '16 09:06 inikulin

But, I've just remembered that it's an intended behavior. If you have a callsite record for unreadable source IMHO it's an exceptional situation. Do you have any ideas how it's can be handled more gracefully?

inikulin avatar Jun 02 '16 09:06 inikulin

Any node.js internal will not be able to be resolved by path. Or if someone has modified the stack trace perhaps.

I think we should check if it exists, and provide an option to throw or swallow it.

vjpr avatar Jun 02 '16 11:06 vjpr

Any node.js internal will not be able to be resolved by path.

Yes and we can't do anything with it.

I think we should check if it exists, and provide an option to throw or swallow it.

It's not a good option either. We should choose between throwing and returning null. But the problem with returning null is that it lacks the context of why it happens.

inikulin avatar Jun 02 '16 11:06 inikulin

Looks like i have a similar problem, when trying to run example snippet: Error: ENOENT: no such file or directory, open 'D:\Work\callsite-test1\example' but i run it from D:\work\callsite-test(1)

georgiy-abbasov avatar Mar 01 '17 12:03 georgiy-abbasov

Was hit by the same when the internet dropped on my instance:

Error: ENOENT: no such file or directory, open 'net.js'
    at Object.openSync (fs.js:439:3)
    at Object.readFileSync (fs.js:344:35)
    at CallsiteRecord.renderSync (D:\code\cfstats\node_modules\callsite-record\lib\index.js:

So it crashed the whole thingy :)

Elyx0 avatar Apr 30 '19 21:04 Elyx0