Skip to content

Incorrect error message received when Sentry DSN not provided #12040

Closed
@whitep4nth3r

Description

@whitep4nth3r

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.0.0

Framework Version

Express 4.17.17

Link to Sentry event

No response

SDK Setup

Sentry.init({
  enabled: true,
  dsn: process.env.NODE_ENV === "production" ? process.env.SENTRY_DSN : "",
  debug: process.env.NODE_ENV !== "production" ? true : false,
  release: process.env.npm_package_version,
  environment: process.env.NODE_ENV,
  sampleRate: 0.5,
  maxBreadcrumbs: 100,
  sendClientReports: true,
  integrations: [nodeProfilingIntegration()],
  tracesSampleRate: 0.5,
  profilesSampleRate: 0.5,
});

Steps to Reproduce

  1. Run dev environment where DSN is not provided (in order to not spam Sentry with bugs in dev)
  2. Observe message in console: [Sentry] Express is not instrumented. This is likely because you required/imported express before calling Sentry.init().
  3. I have confirmed I am importing files in the correct order and using Sentry.setupExpressErrorHandler(app);.
  4. When providing a DSN in dev, the "not instrumented" message is not sent, and Sentry works and logs events as expected.

Expected Result

I should only see:
Sentry Logger [warn]: No DSN provided, client will not send events.
message in the console, and not the:
[Sentry] Express is not instrumented. This is likely because you required/imported express before calling Sentry.init().
message, if my app is set up correctly.

Actual Result

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nodeIssues related to the Sentry Node SDK

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions