I have a function in node which looks like this:
async someFlow() {
try {
func1();
func2();
await getSomeData();
func3();
}
catch (e) {
sentryIo.captureException(e);
}
}
and getSomeData() looks like this:
async getSomeData() {
//... some code
await pgPromise.one('select * from some bad syntax') // line 351!!
//... some code
}
When pgPromise (which is a lib for talking to PostgreSQL) throws an error, the error's stack trace contains only the internal line numbers of the pgPromise lib at which the error happend.
So when the error is being catched and logged to the Sentry.io service I can't know the exact line of the error.
How can I make it so that the error will conatin the stack trace that tells me the error happend in line 351
I ended up doing:
var bb = require('bluebird');
bb.config({longStackTraces: true});
var pgp = require('pg-promise')({promiseLib: bb});
which gave me the complete stack trace for promises.
Memo from the author of pg-promise:
Make sure to have the Long Stack Traces disabled when it goes into production, as sometimes those can have dramatic impact on the performance and memory consumption.