You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello hello! I'm hoping to get a bit of clarification on a specific part of Sentry's docs for getting started with nodejs. In this section Sentry states that when using ESM you should import your instrument file before anything else:
// Import this first!import"./instrument";
I assume this is specifically for projects written in ESM, not necessarily run with ESM. The docs go on to specify that you should use a node --import flag when running with ESM to ensure Sentry is setup before any other modules are imported.
Does that mean the import "./instrument"; code is no longer necessary / could potentially lead to two instances of Sentry's SDK being initialized?
Yeah, all of this is a bit tricky and hard to document.
Our reasoning when writing this was that most people run their apps in CJS mode, so this is what we optimize for in the getting started guide. But I agree that we can add more clarity on this in the ESM code block in the getting started section. e.g. a minimum change could be something along these lines:
// Import this first!import"./instrument";// Note: If you run your application as ESM application, you do not need this.// Instead, you'll need to initialize Sentry in `--import`. See below for details on this.// Now import other modulesimporthttpfrom"http";// Your application code goes here
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hello hello! I'm hoping to get a bit of clarification on a specific part of Sentry's docs for getting started with nodejs. In this section Sentry states that when using ESM you should import your
instrumentfile before anything else:I assume this is specifically for projects written in ESM, not necessarily run with ESM. The docs go on to specify that you should use a node
--importflag when running with ESM to ensure Sentry is setup before any other modules are imported.Does that mean the
import "./instrument";code is no longer necessary / could potentially lead to two instances of Sentry's SDK being initialized?All reactions