openai / openai-quickstart-node

Node.js example app from the OpenAI API quickstart tutorial
https://platform.openai.com/docs/quickstart?context=node
MIT License
2.54k stars 1.99k forks source link

Current Error Handling causing new error for timeouts #47

Closed ianscott313 closed 9 months ago

ianscott313 commented 1 year ago

Describe the bug

Community post of affected users here: https://community.openai.com/t/api-504s-in-production-vercel-only/28795

Vercel users are currently experiencing a timeout issue with OpenAI's API, however, it is not clear the issue is a timeout due to the way error handling has been setup in the quickstart project.

Currently the sample project's fetch completion handler is trying to interpret a json response from an error string. This leads to an unclear error. Uncaught (in promise) SyntaxError: Unexpected token 'A', "An error o"... is not valid JSON

The error handling would be more reliable if we reported on the status rather than assuming we will always get a json response. I created a pull request for it here https://github.com/openai/openai-quickstart-node/pull/46#issue-1569304290

To Reproduce

  1. fork openai-quickstart-node
  2. Login into vercel via github and deploy the project (should take just a few minutes)
  3. In the now deployed environment for openai-quickstart-node, start making large queries to the API
  4. You should start seeing timeouts cause failures but with a weird message like SyntaxError: Unexpected token ...

Solution

Pull request here https://github.com/openai/openai-quickstart-node/pull/46#issue-1569304290

OS

No response

Node version

No response

MuseMatrix commented 1 year ago

{ "message": "Your account is not active, please check your billing details on our website.", "type": "billing_not_active", "param": null, "code": null }

ianscott313 commented 1 year ago

account is active now

lvl-42 commented 1 year ago

In my case this error happens when the 10s timeout is reached. You can check it in vercel logs