Some messages are not appearing in my sentry console, I’m curious is @sentry/node is a singleton?
It seems that for the first file where I call sentry.init, all of those messages are captures, but elsewhere where I require(’@sentry/node’), those messages never appear. Do I have to call init on every instance of sentry in each file that it’s required?
Turns out my issue was due to the process exiting before sentry had completed sending the message. Using the following function fixed my issue:
function exitAfterSentryDrains () {
const client = Sentry.getCurrentHub().getClient()
if (client) {
// Wait for Sentry to drain
// https://docs.sentry.io/error-reporting/configuration/draining/?platform=node
client.close(2000).then(() => {
process.exit()
})
} else {
process.exit()
}
}