sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Fastify integration does not work in ESM mode

Open mohd-akram opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [X] I have reviewed the documentation https://docs.sentry.io/
  • [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.2.1

Framework Version

No response

Link to Sentry event

No response

SDK Setup

// app.mjs
import * as Sentry from "@sentry/node";
import { fastify } from "fastify";
const app = fastify();
Sentry.setupFastifyErrorHandler(app);
const address = await app.listen();
console.info(`server listening on ${address}`);
// instrument.mjs
import * as Sentry from "@sentry/node";
Sentry.init({ dsn: process.env.SENTRY_DSN, debug: true });

Steps to Reproduce

  1. node --import ./instrument.mjs app.mjs

Expected Result

Works

Actual Result

[Sentry] Fastify is not instrumented. This is likely because you required/imported fastify before calling `Sentry.init()`.

mohd-akram avatar May 19 '24 20:05 mohd-akram