Skip to content

Instrument Express with Deno #15048

@NideoTV

Description

@NideoTV

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/deno

SDK Version

8.48.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

// instument.js

import * as Sentry from "npm:@sentry/deno";

Sentry.init({
    debug: true,
    dsn: "...",
    profilesSampleRate: 1.0,
    tracesSampleRate: 1.0,
});

// main.js

import './instrument.js';
import app from './express.js';

// express.js

import * as Sentry from "npm:@sentry/deno";
import express from "npm:express";
const app = express();
Sentry.setupExpressErrorHandler(app);

Steps to Reproduce

deno run -A main.js

Expected Result

I expected Express to be instrumented, or the Sentry Express documentation to specify that "Deno is not supported".

Also we can't use the ESM installation in Deno since "--import" is not available.

Alternate error : Using Sentry/Node package in Deno

I also tried to use the sentry/node package in Deno (replaced every "sentry/deno by sentry/node) and got the same result :

% deno run -A main.js
Sentry Logger [warn]: Failed to register ESM hook TypeError: moduleModule.register is not a function
    at maybeInitializeEsmLoader (file:///Users/nicolasbonzom/Library/Caches/deno/npm/registry.npmjs.org/@sentry/node/8.48.0/build/esm/sdk/initOtel.js:56:22)
    at _init (file:///Users/nicolasbonzom/Library/Caches/deno/npm/registry.npmjs.org/@sentry/node/8.48.0/build/esm/sdk/index.js:111:5)
    at Module.init (file:///Users/nicolasbonzom/Library/Caches/deno/npm/registry.npmjs.org/@sentry/node/8.48.0/build/esm/sdk/index.js:79:10)
    at file:///Users/nicolasbonzom/Documents/expertnet/dev/jobgate-server/instrument.js:3:8
Sentry Logger [log]: Initializing Sentry: process: 89576, thread: main.
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: NodeFetch
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: LocalVariablesAsync
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: ProcessAndThreadBreadcrumbs
Sentry Logger [log]: Integration installed: Express
Sentry Logger [log]: Integration installed: Fastify
Sentry Logger [log]: Integration installed: Graphql
Sentry Logger [log]: Integration installed: Mongo
Sentry Logger [log]: Integration installed: Mongoose
Sentry Logger [log]: Integration installed: Mysql
Sentry Logger [log]: Integration installed: Mysql2
Sentry Logger [log]: Integration installed: Redis
Sentry Logger [log]: Integration installed: Postgres
Sentry Logger [log]: Integration installed: Nest
Sentry Logger [log]: Integration installed: Hapi
Sentry Logger [log]: Integration installed: Koa
Sentry Logger [log]: Integration installed: Connect
Sentry Logger [log]: Integration installed: Tedious
Sentry Logger [log]: Integration installed: GenericPool
Sentry Logger [log]: Integration installed: Kafka
Sentry Logger [log]: Integration installed: Amqplib
Sentry Logger [log]: Integration installed: LruMemoizer
Sentry Logger [log]: Integration installed: vercelAI
Sentry Logger [log]: Running in ESM mode.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for diag v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for trace v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for context v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for propagation v1.9.0.
Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: "http" }
Sentry Logger [debug]: @sentry/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: "http" }
[Sentry] express is not instrumented. Please make sure to initialize Sentry in a separate file that you `--import` when running node, see: https://docs.sentry.io/platforms/javascript/guides/express/install/esm/.

Actual Result

Logs using Sentry/Deno Package

% deno run -A main.js
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: Dedupe
Sentry Logger [log]: Integration installed: Breadcrumbs
Sentry Logger [log]: Integration installed: DenoContext
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: NormalizePaths
Sentry Logger [log]: Integration installed: GlobalHandlers
error: Uncaught (in promise) TypeError: Sentry.setupExpressErrorHandler is not a function
Sentry.setupExpressErrorHandler(app);

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: denoIssues related to the Sentry Deno SDK

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions