Hi,
I’m having a weird issue with the Sentry Node SDK. We have an unhandled rejection handler in our server code that does this:
process.on('unhandledRejection', err => {
throw err
})
(We’re using Kubernetes so even if this code runs and kills our server’s Node process, the pod restarts.) We noticed that unhandled rejections were not getting reported to Sentry. I thought that we could be killing the process before Sentry had actually sent the event from the server. I tried using client.close() as suggested here to allow the events to get sent out, but found that that made no difference, and that the events were still not received. I also tried awaiting on Sentry.flush() but it was the same thing. Doing something like this instead, although it’s pretty horrible, does allow the events to get reported in my testing:
process.on('unhandledRejection', err => {
setTimeout(() => {throw err}, 1000)
})
What is the right way to wait for Sentry to finish sending all its events before running the rest of our unhandled rejection code? I’ve been at this discussion on Github too but many of the suggestions do not work - the events never get reported.