Skip to content

Commit c08b05b

Browse files
authored
fix(node): Allow for undefined transport to be passed in (#15560)
fixes #15558 The Node SDK init options allow for `transport` to be set as `undefined`, but this breaks because of an error `TypeError: options.transport is not a function`. You can see a reproduction of this here: https://stackblitz.com/edit/stackblitz-starters-phh3lfmy?file=index.ts To fix this, we make sure we use `makeNodeTransport` if `options.transport` is set to `undefined`.
1 parent d95ef57 commit c08b05b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/node/src/sdk/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ function getClientOptions(
214214
const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);
215215

216216
const baseOptions = dropUndefinedKeys({
217-
transport: makeNodeTransport,
218217
dsn: process.env.SENTRY_DSN,
219218
environment: process.env.SENTRY_ENVIRONMENT,
220219
sendClientReports: true,
@@ -223,6 +222,7 @@ function getClientOptions(
223222
const overwriteOptions = dropUndefinedKeys({
224223
release,
225224
tracesSampleRate,
225+
transport: options.transport || makeNodeTransport,
226226
});
227227

228228
const mergedOptions = {

packages/node/test/sdk/init.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,9 @@ describe('validateOpenTelemetrySetup', () => {
211211
expect(errorSpy).toBeCalledWith(expect.stringContaining('You have to set up the SentrySpanProcessor.'));
212212
expect(warnSpy).toBeCalledWith(expect.stringContaining('You have to set up the SentrySampler.'));
213213
});
214+
215+
// Regression test for https://github.com/getsentry/sentry-javascript/issues/15558
216+
it('accepts an undefined transport', () => {
217+
init({ dsn: PUBLIC_DSN, transport: undefined });
218+
});
214219
});

0 commit comments

Comments
 (0)