Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry.captureException returns undefined event id due to data racing #6380

Closed
3 tasks done
haritowa opened this issue Dec 1, 2022 · 1 comment · Fixed by #6392
Closed
3 tasks done

Sentry.captureException returns undefined event id due to data racing #6380

haritowa opened this issue Dec 1, 2022 · 1 comment · Fixed by #6392
Assignees
Labels
Package: core Issues related to the Sentry Core SDK Type: Bug

Comments

@haritowa
Copy link

haritowa commented Dec 1, 2022

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/node

SDK Version

7.23.0

Framework Version

v18.9.0

Link to Sentry event

No response

Steps to Reproduce

  1. Record an exception via Sentry.captureException
  2. Observe return result (00000000....)

The problem is with baseclient.js:96

/**
   * @inheritDoc
   */
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
   captureException(exception, hint, scope) {
    // ensure we haven't captured this very object before
    if (utils.checkOrSetAlreadyCaught(exception)) {
      (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log(ALREADY_SEEN_ERROR);
      return;
    }

    let eventId;
    this._process(
      this.eventFromException(exception, hint)
        .then(event => this._captureEvent(event, hint, scope))
        .then(result => {
          eventId = result; <===== it runs second after function exits.
        }),
    );

    return eventId; <===== It runs first. And this value is used in hub.js captureException
  }

Expected Result

Event ID

Actual Result

Undefined which is mapped to 000000...

@AbhiPrasad
Copy link
Member

Hey! This is tricky, and is happening because of #6247, but this breaks because of async event processors.

Will fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: core Issues related to the Sentry Core SDK Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants