Skip to content

Initialization fails with bundled CommonJS #16402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
masinette opened this issue May 23, 2025 · 5 comments
Open

Initialization fails with bundled CommonJS #16402

masinette opened this issue May 23, 2025 · 5 comments

Comments

@masinette
Copy link
Member

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

@getsantry
Copy link

getsantry bot commented May 23, 2025

Assigning to @getsentry/support for routing ⏲️

@getsantry getsantry bot moved this to Waiting for: Support in GitHub Issues with 👀 3 May 23, 2025
@getsantry
Copy link

getsantry bot commented May 27, 2025

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

@getsantry getsantry bot moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3 May 27, 2025
@olksdr
Copy link

olksdr commented May 28, 2025

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

@mydea
Copy link
Member

mydea commented May 28, 2025

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

@mydea mydea transferred this issue from getsentry/sentry May 28, 2025
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 28, 2025
@mydea
Copy link
Member

mydea commented May 28, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants