Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
8.4.0
"openai": "^4.33.1"
Framework Version
Node 8.4.0
Link to Sentry event
No response
SDK Setup
// instrumentation.ts
Sentry.init({
dsn: "",
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: process.env.NODE_ENV === "prod" ? 0.2 : 1,
profilesSampleRate: 1, // Relative to tracesSampleRate
environment: process.env.NODE_ENV,
enabled: process.env.NODE_ENV === "prod",
});
Steps to Reproduce
https://github.com/danilofuchs/sentry-esm-openai-repro
- Add
openai
package - Instrument using
instrumentation.js
file - Run with
node --import ./build/instrumentation.js build/server.js
Expected Result
Runs with Sentry instrumentation.
Perhaps related to #12059 and #12154 (import-in-the-middle bugs)
Actual Result
> node --import ./build/instrumentation.js build/server.js
file:///home/project/node_modules/openai/resources/beta/assistants/files.mjs:51
Files.AssistantFilesPage = FilesAPI.AssistantFilesPage;
^
ReferenceError: Cannot access 'AssistantFilesPage' before initialization
at file:///project/node_modules/openai/resources/beta/assistants/files.mjs:51:41
at file:///home/project/node_modules/openai/resources/beta/assistants/files.mjs:52:3
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.12.2
files.mjs:51:41:
export class AssistantFilesPage extends CursorPage {
}
(function (Files) {
Files.AssistantFilesPage = FilesAPI.AssistantFilesPage;
})(Files || (Files = {}));
//# sourceMappingURL=files.mjs.map
Obs:
Setting globalThis._sentryEsmLoaderHookRegistered = true;
before Sentry.init
fixes the crash but disables auto instrumentation
Metadata
Metadata
Assignees
Type
Projects
Status
No status