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
{{ message }}
Repository navigation
TypeError: Cannot read private member from an object whose class did not declare it at __classPrivateFieldGet #1590
What's strange is that this error typically happens in a container with a Linux environment. In my case, Ubuntu.
I've tried to replicate it but I simply cannot.
Considering downgrading for now but I'm not sure if it's a "langchain/openai" issue, or an "openai" one.
To Reproduce
I'm not even sure, I'm sorry.
i'm creating the openai client via langchain:
new ChatOpenAI({
apiKey: process.env.OPENAI_API_KEY,
modelName: "gpt-4o",
})
We've started to see this error as well. It started occurring when upgrading the package from 5.9.2 to 5.10.1, and oddly, downgrading didn't resolve this issue for us. This also only seems to be occurring for our calls that are using the images.generate functions. Our chat.completions.create are having no issues.
We're making these calls inside a typescript node server (v22). I'm not familiar with the typescript setup but if that's useful information, I can share. I will say that our source code is being compiled to commonjs using swc, so we're importing the openai .js files. Our code is simple enough where we're just creating the client and then calling the API:
@RobertCraigie this issue occurs in my langchain setup.
More specifically, in Langgraph, using the Tavily web search feature.
Now based on @UNLRN's comment, i too had to downgrade far down the road to get it to work as expected
Let me find the exact version
Edit: had to downgrade to a full major version below (4.10) for it work
I am seeing this too when using the Response API in an Electron app (calling the API from the renderer process).
This happens when doing await this.client.responses.create(request)
Call-stack on 5.10.2 is:
Error while generating text TypeError: Cannot read private member from an object whose class did not declare it
at __classPrivateFieldGet (tslib.mjs:14:15)
at Proxy.buildURL (client.ts:446:23)
at Proxy.buildRequest (client.ts:818:22)
at Proxy.makeRequest (client.ts:532:46)
Hi! I was also facing this issue, and like @FaresKi could not repro this locally, but only on the server.
Turns out, the culprit is a Sentry dependency update we had recently: @sentry/[email protected] (which also explains why I couldn't repro locally, because I didn't have Sentry set up for instrumentation on localhost).
I tested three versions of @sentry/node:
9.39 works fine
9.40 (released a week ago) is broken, and leads to the above error
9.41 (released today) is also still broken
Interestingly, the 9.40 release notes are talking about an OpenAI integration, instrumenting openAI API calls. I guess that's the culprit, then (although I don't have this integration enabled currently).
Turns out, the culprit is a Sentry dependency update we had recently: @sentry/[email protected] (which also explains why I couldn't repro locally, because I didn't have Sentry set up for instrumentation on localhost).
I don't depend on Sentry and still facing the issue.
In my case this error was caused by Vue’s reactivity proxy wrapping the OpenAI client instance. Classes with ECMA private fields (#x) break when accessed through a Proxy, which leads to:
import{ref}from"vue";importOpenAIfrom"openai";constclientRef=ref<OpenAI|null>(null);// ❌ Problematic: storing the client in a Vue ref/reactive wraps it in a ProxyclientRef.value=newOpenAI({apiKey: process.env.OPENAI_API_KEY!});// Later:awaitclientRef.value!.chat.completions.create({/* ... */});// -> throws: Cannot read private member...
Fix / Workarounds
Keep the client out of reactivity, or explicitly mark it as non-reactive:
Thanks for reporting this. The SDK intentionally uses JavaScript private fields, which require methods to run with the original client instance as their receiver. Proxy integrations should bind wrapped methods to their original instance. If you use Sentry, upgrade to a version containing its upstream receiver-binding fix; if you use Vue, store the client with markRaw or shallowRef. We are not planning to remove runtime-enforced private fields from the SDK.
Activity
RobertCraigie commentedon Jul 22, 2025
Thanks for the report, can you share more details about your setup? How are you running your code?
UNLRN commentedon Jul 22, 2025
We've started to see this error as well. It started occurring when upgrading the package from 5.9.2 to 5.10.1, and oddly, downgrading didn't resolve this issue for us. This also only seems to be occurring for our calls that are using the
images.generatefunctions. Ourchat.completions.createare having no issues.We're making these calls inside a typescript node server (v22). I'm not familiar with the typescript setup but if that's useful information, I can share. I will say that our source code is being compiled to commonjs using swc, so we're importing the openai
.jsfiles. Our code is simple enough where we're just creating the client and then calling the API:As far as I can tell, the issue (as reported), points to both of the "private" class fields causing issues, here and here.
Once I patched the package to modify the "__classPrivateFieldSet/Get", I know longer see this issue for the image calls.
FaresKi commentedon Jul 22, 2025
@RobertCraigie this issue occurs in my langchain setup.
More specifically, in Langgraph, using the Tavily web search feature.
Now based on @UNLRN's comment, i too had to downgrade far down the road to get it to work as expected
Let me find the exact version
Edit: had to downgrade to a full major version below (4.10) for it work
nbonamy commentedon Jul 23, 2025
I am seeing this too when using the Response API in an Electron app (calling the API from the renderer process).
This happens when doing
await this.client.responses.create(request)Call-stack on 5.10.2 is:
Apparently offending line:
Thanks
marcelgerber commentedon Jul 24, 2025
Hi! I was also facing this issue, and like @FaresKi could not repro this locally, but only on the server.
Turns out, the culprit is a Sentry dependency update we had recently:
@sentry/[email protected](which also explains why I couldn't repro locally, because I didn't have Sentry set up for instrumentation on localhost).I tested three versions of
@sentry/node:Interestingly, the 9.40 release notes are talking about an OpenAI integration, instrumenting openAI API calls. I guess that's the culprit, then (although I don't have this integration enabled currently).
nbonamy commentedon Jul 24, 2025
I don't depend on Sentry and still facing the issue.
marcelgerber commentedon Jul 24, 2025
I could find a minimal repro for the Sentry problem, and have filed that with them now: getsentry/sentry-javascript#17159
UNLRN commentedon Jul 24, 2025
@marcelgerber Thanks for that. It seems like this was also our issue. Downgrading sentry to 9.39 worked for us with using the latest openai version.
nbonamy commentedon Jul 24, 2025
In my case downgrading
openaito 4.104.0 fixes the problem. Tried to the smallest upgrade to 5.0.2 and things start to fail.Interestingly, things work in an isolated node project (https://github.com/nbonamy/multi-llm-ts). In the electron project (https://github.com/nbonamy/witsy), things fail. Given the number of dependencies there, hard to know which one is the problem...
SkinnnyJay commentedon Sep 14, 2025
🚑 #1648
luizzappa commentedon Oct 26, 2025
In my case this error was caused by Vue’s reactivity proxy wrapping the OpenAI client instance. Classes with ECMA private fields (
#x) break when accessed through aProxy, which leads to:How I reproduced it (simplified)
Fix / Workarounds
Keep the client out of reactivity, or explicitly mark it as non-reactive:
nbonamy commentedon Oct 28, 2025
@luizzappa thanks for this! exactly my situation and your fix works!
HAYDEN-OAI commentedon Aug 14, 2026
Thanks for reporting this. The SDK intentionally uses JavaScript private fields, which require methods to run with the original client instance as their receiver. Proxy integrations should bind wrapped methods to their original instance. If you use Sentry, upgrade to a version containing its upstream receiver-binding fix; if you use Vue, store the client with markRaw or shallowRef. We are not planning to remove runtime-enforced private fields from the SDK.