Title: ESM Mode breaks when using openai package · Issue #12237 · getsentry/sentry-javascript · GitHub
Open Graph Title: ESM Mode breaks when using openai package · Issue #12237 · getsentry/sentry-javascript
X Title: ESM Mode breaks when using openai package · Issue #12237 · getsentry/sentry-javascript
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/...
Open Graph 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 th...
X 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 th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/12237
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ESM Mode breaks when using openai package","articleBody":"### Is there an existing issue for this?\r\n\r\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\r\n- [X] I have reviewed the documentation https://docs.sentry.io/\r\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\r\n\r\n### How do you use Sentry?\r\n\r\nSentry Saas (sentry.io)\r\n\r\n### Which SDK are you using?\r\n\r\n@sentry/browser\r\n\r\n### SDK Version\r\n\r\n8.4.0\r\n\r\n\"openai\": \"^4.33.1\"\r\n\r\n### Framework Version\r\n\r\nNode 8.4.0\r\n\r\n### Link to Sentry event\r\n\r\n_No response_\r\n\r\n### SDK Setup\r\n\r\n```js\r\n// instrumentation.ts\r\nSentry.init({\r\n dsn: \"\",\r\n\r\n // Set tracesSampleRate to 1.0 to capture 100%\r\n // of transactions for performance monitoring.\r\n // We recommend adjusting this value in production\r\n tracesSampleRate: process.env.NODE_ENV === \"prod\" ? 0.2 : 1,\r\n profilesSampleRate: 1, // Relative to tracesSampleRate\r\n\r\n environment: process.env.NODE_ENV,\r\n enabled: process.env.NODE_ENV === \"prod\",\r\n});\r\n\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\nhttps://github.com/danilofuchs/sentry-esm-openai-repro\r\n\r\n1. Add `openai` package\r\n2. Instrument using `instrumentation.js` file\r\n3. Run with `node --import ./build/instrumentation.js build/server.js`\r\n\r\n### Expected Result\r\n\r\nRuns with Sentry instrumentation.\r\n\r\nPerhaps related to https://github.com/getsentry/sentry-javascript/issues/12059 and https://github.com/getsentry/sentry-javascript/issues/12154 (import-in-the-middle bugs)\r\n\r\n### Actual Result\r\n\r\n```\r\n> node --import ./build/instrumentation.js build/server.js\r\n\r\nfile:///home/project/node_modules/openai/resources/beta/assistants/files.mjs:51\r\n Files.AssistantFilesPage = FilesAPI.AssistantFilesPage;\r\n ^\r\n\r\nReferenceError: Cannot access 'AssistantFilesPage' before initialization\r\n at file:///project/node_modules/openai/resources/beta/assistants/files.mjs:51:41\r\n at file:///home/project/node_modules/openai/resources/beta/assistants/files.mjs:52:3\r\n at ModuleJob.run (node:internal/modules/esm/module_job:222:25)\r\n at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)\r\n at async loadESM (node:internal/process/esm_loader:28:7)\r\n at async handleMainPromise (node:internal/modules/run_main:113:12)\r\n\r\nNode.js v20.12.2\r\n```\r\n\r\nfiles.mjs:51:41:\r\n```js\r\nexport class AssistantFilesPage extends CursorPage {\r\n}\r\n(function (Files) {\r\n Files.AssistantFilesPage = FilesAPI.AssistantFilesPage;\r\n})(Files || (Files = {}));\r\n//# sourceMappingURL=files.mjs.map\r\n```\r\n\r\nObs:\r\nSetting `globalThis._sentryEsmLoaderHookRegistered = true;` before `Sentry.init` fixes the crash but disables auto instrumentation","author":{"url":"https://github.com/danilofuchs","@type":"Person","name":"danilofuchs"},"datePublished":"2024-05-27T15:01:09Z","url":"https://github.com/getsentry/sentry-javascript/issues/12237"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c671c6bb-566f-f744-24eb-f1d80eeecfcd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D08:1752F1:1BCDE74:2387983:6B03C3D9 |
| html-safe-nonce | ecb298a6d3066d679e898927d511ca97ebda893302a3813161253d2c2f8940f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDA4OjE3NTJGMToxQkNERTc0OjIzODc5ODM6NkIwM0MzRDkiLCJ2aXNpdG9yX2lkIjoiNTczNzAwOTgzNDUxMjA3MzY4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 099207e5cf5ed290ee1fe50a5405a4fa07d5d1dd5afdee4e092ed15910ee94fe |
| hovercard-subject-tag | issue:2319353466 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/12237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0f0dba117418e4a9859de8ff830490f2117e9486cf4b01756ba222afabc99156/getsentry/sentry-javascript/issues/12237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0f0dba117418e4a9859de8ff830490f2117e9486cf4b01756ba222afabc99156/getsentry/sentry-javascript/issues/12237 |
| og:image:alt | 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 th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danilofuchs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width