NextJS navigator is not defined - azure v4 stream true
Problem
Describe the bug using last v4 server side, there is an error when calling for example chat.create here https://github.com/openai/openai-node/blob/3ec43ee790a2eb6a0ccdd5f25faa23251b0f9b8e/src/core.ts#L806 you can see code: if (!navigator || typeof navigator === 'undefined') { it is checking if it is undefined "after" trying to use it with !navigator To Reproduce calling chat.completions.create with stream true. but using it on Azure from this sample https://github.com/openai/openai-node/blob/3ec43ee790a2eb6a0ccdd5f25faa23251b0f9b8e/examples/azure.ts#L5 Code snippets _No response_ OS macOS Node version node 18 Library version v4.0.0
Error Output
error when calling for example chat.create
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: NextJS navigator is not defined - azure v4 stream true
Hi @UXDart , thanks for reporting this. You list your Node version as 18; can you share more details of your environment? A preceding call should have early-returned, and I'm surprised it didn't: https://github.com/openai/openai-node/blob/3ec43ee790a2eb6a0ccdd5f25faa23251b0f9b8e/src/core.ts#L763 What does `Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0)` return in yo
Trust Score
1 verification
- 1
Hi @UXDart , thanks for reporting this. You list your Node version as 18; can yo
Hi @UXDart , thanks for reporting this. You list your Node version as 18; can you share more details of your environment?
- 2
A preceding call should have early-returned, and I'm surprised it didn't:
https://github.com/openai/openai-node/blob/3ec43ee790a2eb6a0ccdd5f25faa23251b0f9b8e/src/core.ts#L763
- 3
What does `Object.prototype.toString.call(typeof process !== 'undefined' ? proce
What does `Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0)` return in your system?
Validation
Resolved in openai/openai-node GitHub issue #226. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep