sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Add integration for 'multipleResolves' event

Open iatsiuk opened this issue 6 years ago • 3 comments

  • [x] Review the documentation: https://docs.sentry.io/
  • [x] Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
  • [x] Use the latest release: https://github.com/getsentry/sentry-javascript/releases

Package + Version

  • [ ] @sentry/browser
  • [x] @sentry/node
  • [ ] raven-js
  • [ ] raven-node (raven for node)
  • [ ] other:

Version:

@sentry/[email protected]

Description

The 'multipleResolves' event is emitted whenever a Promise has been either:

  • Resolved more than once.
  • Rejected more than once.
  • Rejected after resolve.
  • Resolved after reject.

Node.js v11.6.0 Documentation link.

iatsiuk avatar Jan 15 '19 22:01 iatsiuk

We happily accept PRs for this :)

HazAT avatar Jan 16 '19 09:01 HazAT

I don't know TypeScript, sorry for that.

I'm using this snippet for now:

process.on('multipleResolves', async (type, promise, value) => {
  let originalVal;

  try {
    originalVal = await promise;
  } catch (err) {
    originalVal = err.stack && err.message ? err.message : err;
  }

  const swallowedVal = value.stack && value.message ? value.message : value;
  const multipleResolvesError = new Error(
    [
      `Swallowed promise ${type}`,
      `original value: ${JSON.stringify(originalVal)}`,
      `swallowed: ${JSON.stringify(swallowedVal)}.`
    ].join(', ')
  );

  Sentry.captureException(multipleResolvesError);
});

iatsiuk avatar Jan 16 '19 13:01 iatsiuk

This is already really helpful, thanks 💯 When we find some time we will implement a pluggable integration for this.

HazAT avatar Jan 16 '19 14:01 HazAT