Cannot read property 'getFileName' of undefined
This is how I'm using it...
promiseFunction().then(doStuff).catch(logger.error)
The result: Cannot read property 'getFileName' of undefined
This line: https://github.com/trentm/node-bunyan/blob/master/lib/bunyan.js#L195
What is going wrong here?
What is going wrong is that stack trace information is simply not available in some contexts of a promise, therefore the caller variable must be checked before being used.
I found this as well. did this solution eventually make it out to a release of the npm module? I am finding it hard to follow the forks. thanks!
I also ran into this issue. console.error() seems to log these just fine, although ideally I'd like to use Bunyan instead... I'm not really seeing a pattern as to why it would trip Bunyan, the console.error() stack trace seems to provide full context (file name, line number, and function name).
Here is an example of one I bottled up with console.error() and later fixed:
TypeError: module.exports.DB.collection(...).dropCollection is not a function
at Promise (/batscloud/database/database-mongodb.js:282:45)
at Object.module.exports.DropCollection (/batscloud/database/database-mongodb.js:280:9)
at HandleSynchronization.Controller.SynchronizationPatchCache.reconstruct.then (/batscloud/deploymentController/deploymentController.js:243:25)
Try adding this fix here with patch-package (note I haven't tested yet): https://github.com/trentm/node-bunyan/blob/master/lib/bunyan.js#L188
var caller = stack[2];
if (!caller) {
return;
}