Improve pg-promise stack traces

Reading Time: < 1 minutes

When you execute a query with error, we get a
internal module-specific stack trace. That’s not really helpful, right?

What we want is to know which of our methods executed a query that failed

To do that we just tell pg-promise that uses bluebird as a promise lib

const bluebird = require('bluebird');
bluebird.config({ longStackTraces: true });
const pgp = require('pg-promise')({ promiseLib: bluebird });

Important: we have to set longStackTraces to false on production environments to avoid performance issues in termos of memory and CPU usage.

Photo by eberhard grossgasteiger on Unsplash

About the author

Andrés Canavesi
Andrés Canavesi

Software Engineer with 15+ experience in software development, specialized in Salesforce, Java and Node.js.

Related posts

Leave a Reply

%d bloggers like this: