Skip to content

Sentry.startTransaction fails in Node 18.12.1 + TS #8091

Closed
@DanielMSchmidt

Description

@DanielMSchmidt

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

7.51.2

Framework Version

No response

Link to Sentry event

No response

SDK Setup

Sentry.init({
	dsn: __MY_DSN__,
	tracesSampleRate: 1.0,
});

Steps to Reproduce

  1. Create a project using TS 5.0.4
  2. Use a tsconfig.json like this
{
  "compilerOptions": {
    "outDir": "lib",
    "allowJs": true,
    "alwaysStrict": true,
    "declaration": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "inlineSources": true,
    "sourceRoot": "/",
    "lib": ["es2022"],
    "module": "CommonJS",
    "noEmitOnError": false,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "resolveJsonModule": true,
    "strict": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true,
    "stripInternal": true,
    "skipDefaultLibCheck": true,
    "target": "ES2020",
    "incremental": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "moduleResolution": "nodenext"
  },
  "include": ["src/**/*.ts", "test/**/*.ts"],
  "exclude": ["node_modules/", "**/*.d.ts"]
}
  1. Create a trace in e.g. src/index.ts
import * as Sentry from "@sentry/node";
Sentry.init({
	dsn: __MY_DSN__,
	tracesSampleRate: 1.0,
});
const transaction = Sentry.startTransaction({ name: "demo" });
transaction.finish()
  1. Run tsc
  2. Execute node lib/src/index.js

Expected Result

Traces being tracked

Actual Result

Error is thrown on startTransactiion:

TypeError: Cannot read properties of undefined (reading '0')
    at /my-project/node_modules/@sentry/core/node_modules/@sentry/utils/cjs/misc.js:21:87
    at /my-project/node_modules/@sentry/core/node_modules/@sentry/utils/cjs/misc.js:27:15
    at [Symbol.replace] (<anonymous>)
    at String.replace (<anonymous>)
    at Object.uuid4 (/my-project/node_modules/@sentry/core/node_modules/@sentry/utils/cjs/misc.js:25:46)
    at Span.__init2 (/my-project/node_modules/@sentry/core/cjs/tracing/span.js:40:36)
    at new Span (/my-project/node_modules/@sentry/core/cjs/tracing/span.js:107:53)
    at Transaction.startChild (/my-project/node_modules/@sentry/core/cjs/tracing/span.js:156:23)

It appears to be related to this line: https://github.com/getsentry/sentry-javascript/blob/develop/packages/utils/src/misc.ts#L33
My guess is that Uint8Array is not globally defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: coreIssues related to the Sentry Core SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions