-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Error: Premature close in streaming mode, seems it is related to timeout #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for reporting this. Can you paste an error that is thrown after you set Can you share a prompt that takes this amount of time for repro? |
It also Premature Close error. This error thrown after 10 minutes, which means timeout setting(20 minutes) passed is not working. Error: Premature close
at IncomingMessage.<anonymous> (/home/dev/refri_be/data-process/node_modules/node-fetch/lib/index.js:1748:18)
at Object.onceWrapper (node:events:631:28)
at IncomingMessage.emit (node:events:517:28)
at emitCloseNT (node:internal/streams/destroy:132:10)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'ERR_STREAM_PREMATURE_CLOSE'
}
This is minimal reproduction: try this at api-busy time. https://github.com/Istiopaxx/openai-node-bug-report |
Interesting, that script runs for me in 72s. I may have a hard time reproducing this from where I sit in the USA. Can you confirm that the same requests made over curl don't suffer from the same problem? I think this might be a server-or-gateway-side timeout rather than a client timeout. |
I tried curl, and it also stopped after 600s. I checked my home gateway timeout setting but i found no timeout setting related. I searched for this topic so much but could not find any helpful solution. I guess openai api's tier system makes response of my api calls slower(cause i'm in tier 2), and probably 600s timeout can be related to that. Nothing is certain about this 😢 Searched pages: |
Thank you @Istiopaxx, and sorry to hear about your difficulties! I might recommend opening a new thread at community.openai.com about the 10min API timeout affecting you. |
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
My code use chat completion api create func with stream:true, and takes so long time: over 10 minutes(default timeout setting).
This request makes long -over 10 minutes-stream and after 10 minutes the request fails with error:
I tried to chage timeout setting by passing
timeout: 20 * 60 * 1000
both increate
function andOpenAi
constructor, but not worked. I checked #294 but nothing was helpful..node-fetch
's Premature close error is due to streaming timeout, this error should be handled by this library and transfer to proper error, e.g.APIConnectionTimeoutError
.To Reproduce
OpenAI.chat.completions.create
withstream:true
and wait for 10 minutesCode snippets
No response
OS
macOS sonoma
Node version
18.18.2
Library version
4.14.2
The text was updated successfully, but these errors were encountered: