Skip to content

Using Express on Lambda fails to add tracing data into Sentry #18122

@joshhornby

Description

@joshhornby

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/aws-serverless

SDK Version

10.22.0

Framework Version

Express 4.21.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

Running an Express application on AWS Lambda using codegenie/serverless-express

This is being deployed as a CJS application

import * as Sentry from '@sentry/aws-serverless';

Sentry.init({
  debug: true,
  dsn: process.env.SENTRY_DSN,
  environment: 'staging',
  integrations: [
    Sentry.expressIntegration()
  ],
  tracesSampleRate: 1.0,
});

import express from 'express';
import serverlessExpress from '@codegenie/serverless-express';

const app = express();
app.get('/debug-sentry', (_req, res) => res.status(200).send('OK'));

app.use(Sentry.expressErrorHandler());

const serverlessExpressInstance = serverlessExpress({ app });

export const handler = Sentry.wrapHandler((event, context, callback) => {
  context.callbackWaitsForEmptyEventLoop = false;
  return serverlessExpressInstance(event, context, callback);
});

Steps to Reproduce

Deploying the above on a Lambda produces the following debug logs:

2025-11-07T20:16:18.262+00:00
INIT_START Runtime Version: nodejs:22.v59 Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:9ff8926a0b8f846a2bd170efff02668e0f0f00b647d56d4fdc31c22b5cef37a8
2025-11-07T20:16:18.571+00:00
2025-11-07T20:16:18.571Z undefined INFO Sentry Logger [log]: Initializing Sentry: process: 2, thread: main.
2025-11-07T20:16:18.586+00:00
2025-11-07T20:16:18.586Z undefined INFO Sentry Logger [log]: Integration installed: InboundFilters
2025-11-07T20:16:18.587+00:00
2025-11-07T20:16:18.587Z undefined INFO Sentry Logger [log]: Integration installed: FunctionToString
2025-11-07T20:16:18.587+00:00
2025-11-07T20:16:18.587Z undefined INFO Sentry Logger [log]: Integration installed: LinkedErrors
2025-11-07T20:16:18.587+00:00
2025-11-07T20:16:18.587Z undefined INFO Sentry Logger [log]: Integration installed: RequestData
2025-11-07T20:16:18.588+00:00
2025-11-07T20:16:18.588Z undefined INFO Sentry Logger [log]: Integration installed: NodeSystemError
2025-11-07T20:16:18.588+00:00
2025-11-07T20:16:18.588Z undefined INFO Sentry Logger [log]: Integration installed: Console
2025-11-07T20:16:18.588+00:00
2025-11-07T20:16:18.588Z undefined INFO Sentry Logger [log]: Integration installed: OnUncaughtException
2025-11-07T20:16:18.588+00:00
2025-11-07T20:16:18.588Z undefined INFO Sentry Logger [log]: Integration installed: OnUnhandledRejection
2025-11-07T20:16:18.589+00:00
2025-11-07T20:16:18.589Z undefined INFO Sentry Logger [log]: Integration installed: ContextLines
2025-11-07T20:16:18.589+00:00
2025-11-07T20:16:18.589Z undefined INFO Sentry Logger [log]: Integration installed: LocalVariablesAsync
2025-11-07T20:16:18.589+00:00
2025-11-07T20:16:18.589Z undefined INFO Sentry Logger [log]: Integration installed: Context
2025-11-07T20:16:18.589+00:00
2025-11-07T20:16:18.589Z undefined INFO Sentry Logger [log]: Integration installed: ChildProcess
2025-11-07T20:16:18.590+00:00
2025-11-07T20:16:18.590Z undefined INFO Sentry Logger [log]: Integration installed: ProcessSession
2025-11-07T20:16:18.590+00:00
2025-11-07T20:16:18.590Z undefined INFO Sentry Logger [log]: Integration installed: Modules
2025-11-07T20:16:18.593+00:00
2025-11-07T20:16:18.593Z undefined INFO Sentry Logger [log]: Integration installed: Http
2025-11-07T20:16:18.594+00:00
2025-11-07T20:16:18.594Z undefined INFO Sentry Logger [log]: Integration installed: NodeFetch
2025-11-07T20:16:18.598+00:00
2025-11-07T20:16:18.598Z undefined INFO Sentry Logger [log]: Integration installed: Aws
2025-11-07T20:16:18.600+00:00
2025-11-07T20:16:18.600Z undefined INFO Sentry Logger [log]: Integration installed: AwsLambda
2025-11-07T20:16:18.600+00:00
2025-11-07T20:16:18.600Z undefined INFO Sentry Logger [log]: Integration installed: Express
2025-11-07T20:16:18.601+00:00
2025-11-07T20:16:18.601Z undefined INFO Sentry Logger [log]: SDK initialized from CommonJS
2025-11-07T20:16:18.601+00:00
2025-11-07T20:16:18.601Z undefined INFO Sentry Logger [log]: @opentelemetry/api: Registered a global for diag v1.9.0.
2025-11-07T20:16:18.603+00:00
2025-11-07T20:16:18.603Z undefined INFO Sentry Logger [log]: @opentelemetry/api: Registered a global for trace v1.9.0.
2025-11-07T20:16:18.604+00:00
2025-11-07T20:16:18.604Z undefined INFO Sentry Logger [log]: @opentelemetry/api: Registered a global for propagation v1.9.0.
2025-11-07T20:16:18.604+00:00
2025-11-07T20:16:18.604Z undefined INFO Sentry Logger [log]: @opentelemetry/api: Registered a global for context v1.9.0.
2025-11-07T20:16:18.612+00:00
START RequestId: 18dcc334-9cf5-4ea9-9147-89820d5cf69b Version: $LATEST
2025-11-07T20:16:18.625+00:00
2025-11-07T20:16:18.625Z 18dcc334-9cf5-4ea9-9147-89820d5cf69b INFO Sentry Logger [log]: SpanExporter exported 0 spans, 0 spans are waiting for their parent spans to finish
2025-11-07T20:16:18.625+00:00
2025-11-07T20:16:18.625Z 18dcc334-9cf5-4ea9-9147-89820d5cf69b INFO Sentry Logger [log]: Flushing outcomes...
2025-11-07T20:16:18.625+00:00
2025-11-07T20:16:18.625Z 18dcc334-9cf5-4ea9-9147-89820d5cf69b INFO Sentry Logger [log]: No outcomes to send
2025-11-07T20:16:18.630+00:00
END RequestId: 18dcc334-9cf5-4ea9-9147-89820d5cf69b
2025-11-07T20:16:18.630+00:00
REPORT RequestId: 18dcc334-9cf5-4ea9-9147-89820d5cf69b Duration: 17.34 ms Billed Duration: 365 ms Memory Size: 1024 MB Max Memory Used: 108 MB Init Duration: 346.86 ms

Expected Result

Traces to show in Sentry UI

Actual Result

Nothing can be seen in backend traces in Sentry UI. This is confirmed by the debug logs showing SpanExporter exported 0 spans, 0 spans are waiting for their parent spans to finish

I've successfully been able to see an error arrive in Sentry with the above setup.

Additional Context

This feels related to this comment #13871 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions