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

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

Closed
3 tasks done
steveatkoan opened this issue Dec 9, 2024 · 6 comments
Closed
3 tasks done

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

steveatkoan opened this issue Dec 9, 2024 · 6 comments
Assignees
Labels
Package: node Issues related to the Sentry Node SDK

Comments

@steveatkoan
Copy link

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

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 9, 2024
@github-actions github-actions bot added the Package: node Issues related to the Sentry Node SDK label Dec 9, 2024
@dim0627
Copy link

dim0627 commented Dec 10, 2024

Same here with NestJS

@Lms24
Copy link
Member

Lms24 commented Dec 10, 2024

Hi, thanks for writing in! We'll take a look today.

@Lms24
Copy link
Member

Lms24 commented Dec 10, 2024

Actually one question: Is anyone of you importing (types) from other packages like @sentry/types or @sentry/utils?

@Lms24 Lms24 self-assigned this Dec 10, 2024
@Lms24
Copy link
Member

Lms24 commented Dec 10, 2024

In addition, please check if all your installed @sentry/* packages, including all dependencies of your top level SDK (e.g. `@sentry/node), are aligned to the same version. My suspicion is that #14271 might be causing the issue but it should not be problematic (or breaking) if all Sentry dependencies are on the same version.

Update: I created a fastify sample project with typescript and could not reproduce this issue. At this time I'm fairly certain that this is a dependency version mismatch error. Adding the "Waiting for Community" label.

We will not continue investigating this for now until we hear back from affected users.

@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 Dec 10, 2024
@steveatkoan
Copy link
Author

Thanks for the super quick response. This is fixed now in @sentry/node 8.43.0 released a few hours ago

@Lms24
Copy link
Member

Lms24 commented Dec 10, 2024

Thanks for the update! #14576 might have had something to do with it. Glad it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: node Issues related to the Sentry Node SDK
Projects
Archived in project
Development

No branches or pull requests

3 participants