Skip to content

All global breadcrumbs appear in all captured exceptions. #3120

Closed
@alarbada

Description

@alarbada

Package + Version

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

Version:

sentry.javascript.node

5.29.0

Description

Describe your issue in detail, ideally, you have a reproducible demo that you can show.

I can't understand why the following code:

const main = async () => {
    Sentry.addBreadcrumb({
        message: 'first'
    })

    Sentry.captureException(new Error('err1'))

    Sentry.addBreadcrumb({
        message: 'second'
    })

    Sentry.captureException(new Error('err2'))

    Sentry.addBreadcrumb({
        message: 'third'
    })

    Sentry.captureException(new Error('err3'))
}

main()

produces 3 exceptions with all three breadcrumbs. I'd expect:

  • Error err1 to have the breadcrumb 'first'
  • Error err2 to have the breadcrumb 'first' and 'second'
  • Error err3 to have the breadcrumb 'first', 'second' and 'third'.

I believe this is a bug, because I can achieve my desired behaviour using captureMessage.

const main = async () => {
    Sentry.addBreadcrumb({
        message: 'first'
    })

    Sentry.captureMessage(new Error('err1'))

    Sentry.addBreadcrumb({
        message: 'second'
    })

    Sentry.captureMessage(new Error('err2'))

    Sentry.addBreadcrumb({
        message: 'third'
    })

    Sentry.captureMessage(new Error('err3'))
}

main()

Here the captured messages have the proper breadcrumbs that I want. In fact, I'd go with captureMessage, but with it I loose stack traces, and it's less semantic. So what's up with captureException? Am I missing something? The docs don't explain this behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nodeIssues related to the Sentry Node SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions