Skip to content

Sentry.withScope not properly clearing breadcrumbs from previous executions.. #3200

@empz

Description

@empz

Package + Version

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

Version:

6.0.2

Description

I'm following the example provided to integrate it with an Azure Function. Here's how my code looks like simplified:

const Sentry = require("@sentry/node");
Sentry.init({
  dsn: process.env["SENTRY_DSN"],
  environment: process.env["ENVIRONMENT"] || "PROD",
  sendDefaultPii: true,
});

module.exports = async function (context, myQueueItem) {
return new Promise((resolve, reject) => {
    Sentry.withScope(async (scope) => {
      try {
        // setting some context and tags
        scope.setContext("Queue Item", myQueueItem);
        scope.setTags({...});
        
        // do stuff
      }
      catch (e) {
        Sentry.captureException(e);
        await Sentry.flush(2000);

        reject(e);
      }
      finally {
        // some cleanup code...
        resolve();
      }
}

When an error is captured and sent to Sentry I can see it has breadcrumbs from previous executions instead of just the single one that throw.
Also, the context and tags are nowhere to be seen on the event.

Am I doing something wrong? If I do, could you please provide a full Azure Function example? This sample doesn't demonstrate how to properly scope context/tags to a single function invocation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions