sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Initialization fails with bundled CommonJS

Open masinette opened this issue 5 months ago • 5 comments
trafficstars

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

masinette avatar May 23 '25 19:05 masinette

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar May 23 '25 19:05 getsantry[bot]

Routing to @getsentry/product-owners-ingestion-and-filtering for triage ⏲️

getsantry[bot] avatar May 27 '25 20:05 getsantry[bot]

@mydea i'm not sure if this is something for your team? It seems like got mislabeled and assigned to ingest instead.

olksdr avatar May 28 '25 05:05 olksdr

Hey, this is a JS SDK issue, moving it to sentry-javascript!

mydea avatar May 28 '25 07:05 mydea

If the content is bundled, they may need to configure things as external to work - instrumentation only works for external dependencies, not bundles one, as of now, sadly :/ So you'll need to make e.g. pg external. Can you try of that works?

mydea avatar May 28 '25 07:05 mydea

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

getsantry[bot] avatar Jul 23 '25 07:07 getsantry[bot]