GeezerVison is showing github.com — SDK fails in ESM mode in combination with openai · Issue #12414 · getsentry/sentry-javascript
SDK fails in ESM mode in combination with openai #12414DescriptionIs there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.8.0
Framework Version
Node 20.14.0
Link to Sentry event
https://trainwell.sentry.io/issues/5463070600/?project=6067364&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=14d&stream_index=1
SDK Setup
Sentry.init({
dsn: "[REDACTED]",
});
Steps to Reproduce
- Add
openai package
- Instrument using instrumentation.js file
- Run with node --import ./dist/instrumentation.js dist/index.js
The addition of the following code is what triggers the issue:
import OpenAI from "openai";
const openAI = new OpenAI({
apiKey: "[REDACTED]",
});
Expected Result
App builds with sentry instrumentation and no errors.
Actual Result
I receive the following error:
TypeError: API.Completions is not a constructor
at new OpenAI (file:///[REDACTED]/node_modules/.pnpm/[email protected]/node_modules/openai/index.mjs:46:28)
at file:///[REDACTED]
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
This might be related to #12237 however it appears to be a unique issue unrelated to initialization. Reacted by Hudo Assenco, Danilo Fuchs, Nato Boram and Sergio Moreno ActivityLms24 commented on Jun 10, 2024 Hey @Xhale1 thanks for reporting!
Just to rule something out: Which version of openai are you using? It seems there were related issues in an older version. Thanks! hudovisk commented on Jun 10, 2024 Same issue here, using openai: 4.47.3
Xhale1 commented on Jun 10, 2024 Thanks for checking in! Just confirmed that my issue exists with version 4.49.1 which appears to be the latest offered by openai.
Let me know if a reproduction repo would help Lms24 commented on Jun 10, 2024 A reproduction would be greatly appreciated, thanks :) Xhale1 commented on Oct 17, 2024 Hello! I'm sorry for not closing the loop here earlier.
Using the onlyIncludeInstrumentedModules option is working great and has solved the original issue! I'm also happy to report my team has fully migrated to v8 thanks to this option 🎉
I'll leave this issue open on the oft chance @timfish wants to use it to track openai compatibility without this option, but feel free to close whenever you see fit :)
Thank you everyone for your dedication to this issue and to the larger open source community :) Reacted by Luca Forstner and Torick Davis Ivan-juni commented on Nov 15, 2024 How can i use onlyIncludeInstrumentedModules with the late initialization (preload)? andreiborza commented on Nov 18, 2024 @Ivan-juni you currently can't but we could provide that option via an env variable. I added this to our backlog: #14330 timfish commented on Feb 21, 2025 For v9 of the SDKs, the onlyIncludeInstrumentedModules option has been removed because this mode is now enabled by default. The incompatibility with openai should no longer exist.
MetadataMetadataStatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|