TooTallNate / node-bindings

Helper module for loading your native module's `.node` file
MIT License
412 stars 95 forks source link

Fix undefined fileName in getFileName #68

Open brandon-fry opened 4 years ago

brandon-fry commented 4 years ago

When attempting to find the file name of the caller, getFileName grabs a stack trace and attempts to walk up it to find the first file name that is not the bindings.js file. For some reason, in my environment, the bindings.js file name is 'undefined' (see output below). In this case 'undefined' !== __filename and the for loop is stopped, leaving fileName undefined and causing an error when indexOf is invoked on fileName. To fix, an additional check for undefined fileName is added in the loop.

fileName: undefined function: getFileName fileName: undefined function: bindings fileName: undefined function: eval fileName: /projects/node-crfpp/node-crfpp-bundle.js function: ./node-crfpp.js

brandon-fry commented 4 years ago

Potential fix for #54

eden-lane commented 2 years ago

Any progress on this?

nicolaichuk commented 2 years ago

@TooTallNate Please review and merge to upstream.