Recently, we saw a steep increase of errors titled Event CustomEvent (type=unhandledrejection) captured as promise rejection
in Sentry. Based on the research so far, it looks like a promise gets rejected somewhere in the code, but we have not yet been able to find where this happens. I’ve already added below piece of code to log a trace entry with some information about the rejected event, but apparently the reason
is undefined
. I know there is also a promise
property on the listener argument, but I don’t know how to get any useful information from that object. Is it possible to determine the source of a promise, and if so, how?
window.addEventListener('unhandledrejection', ({ reason }) => {
ErrorManagement.addTrace({
data: { reason },
level: 'info',
message: 'unhandledrejection caught',
category: 'error',
});
});