Skip to content

'dsn' does not exist in type 'BaseNodeOptions'. Fastify #14627

@steveatkoan

Description

@steveatkoan

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.42.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

Currently using @sentry/node 8.40.0 for a fastify / typescript project using latest of all packages. When I do "yarn upgrade" to update to @sentry/node 8.42.0, i see an error when using tsc to compile

src/sentry.ts:22:3 - error TS2353: Object literal may only specify known properties, and 'dsn' does not exist in type 'BaseNodeOptions'.

22   dsn: Environment.getSentryDSN(),
     ~~~

src/sentry.ts:38:19 - error TS7006: Parameter 'samplingContext' implicitly has an 'any' type.

38   tracesSampler: (samplingContext) => {
                     ~~~~~~~~~~~~~~~

Found 2 errors in the same file, starting at: src/sentry.ts:22

My src/sentry.ts contains

import * as Sentry from '@sentry/node';
import { Environment } from 'src/utils/Environment.js';

Sentry.init({
  dsn: Environment.getSentryDSN(),
  environment: Environment.getEnvironmentName(),
  release: Environment.getBuildNumber(),
  enabled: Environment.isProduction(), 
  debug: Environment.isDevelopment(),
  registerEsmLoaderHooks: true,
  sampleRate: 1,
  tracesSampler: (samplingContext) => {
    if (samplingContext.name.endsWith('basic404')) {
      // don't log 404s generated by fastify: probably just a bot looking for vulnerabilities
      return 0;
    }
    return 1;
  },
...
});

which works with 8.40.0 and does not with 8.42.0.

Expected Result

Upgrading from a minor version to a subsequent minor version should not break code.
Your docs https://docs.sentry.io/platforms/javascript/guides/fastify/ say 'dsn' is still the correct thing to use

Actual Result

Compile fail as above

Metadata

Metadata

Assignees

Labels

BugPackage: nodeIssues related to the Sentry Node SDK

Projects

Status

Waiting for: Community

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions