Skip to content

Initialization fails with bundled CommonJS #16402

Open
@masinette

Description

@masinette

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

User issue:
Initializing Sentry works when running it in a dev environment, but fails to initialize when using a CommonJS bundled file.

------------First 2 lines of CommonJs bundled server file server.js-------------------

"use strict";
require("./instrument");

---------- contents of instrument.js ----------------

const Sentry = require("@sentry/node");
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
console.log("initializing Sentry for bundle");
const node = Sentry.init({
    dns: 'https://{{redacted}}',
    integrations: [
        // Add our Profiling integration
        nodeProfilingIntegration(),
        Sentry.postgresIntegration(),
        Sentry.expressIntegration(),
    ],
    debug: true,
    beforeSend: (ev, hint) => {
        console.log("Sentry sending ", { ev, hint })
        return ev;
    },
    // Add Tracing by setting tracesSampleRate
    // We recommend adjusting this value in production
    tracesSampleRate: 1.0,

    // Set sampling rate for profiling
    // This is relative to tracesSampleRate
    profilesSampleRate: 1.0,
    environment: `test-local`
});
console.log("initialized Sentry for bundle");
  • instrument.js is being required at the top of the main file, in the beginning of the application

  • logs in ticket #152026

Expected Result

Sentry should initialize successfully and send events

Actual Result

Sentry does not initialize

Product Area

Ingestion and Filtering

Link

No response

DSN

No response

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions