Skip to content
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

Getting Unhandled Rejection event, randomly. #959

Open
1 task done
mManishTrivedi opened this issue Jul 29, 2024 · 3 comments
Open
1 task done

Getting Unhandled Rejection event, randomly. #959

mManishTrivedi opened this issue Jul 29, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@mManishTrivedi
Copy link

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • This is an issue with the Node library

Describe the bug

A Node.js library is throwing an unhandled promise rejection error due to improper error handling.

To Reproduce

How to reproduce this issue:

  • run and stream, then add an event listener to the stream.
  • Attempt to run and stream again on the same thread ID. This will trigger an unhandled rejection, causing your Node server to crash if there is no global error handler in place.

Ideally, this error should be handled with stream.on('error', myCustomErrorHandler).

Code snippets

No response

OS

macOs

Node version

v18.19.0

Library version

openai 4.52.7

@mManishTrivedi mManishTrivedi added the bug Something isn't working label Jul 29, 2024
@RobertCraigie
Copy link
Collaborator

Hi can you share an example script? (it doesn't have to reliably reproduce this issue as you've mentioned you're only seeing it sporadically)

@mManishTrivedi
Copy link
Author

@RobertCraigie
I haven't observed this issue in the last day. I have updated the OpenAI module. Let's monitor it for the next 1-2 days. If the issue persists, I will share a code snippet for reproduction.

@mManishTrivedi
Copy link
Author

I encountered this error randomly after some retries on the same thread.

For example, if I post a message on a thread and receive the error message Final run has not been received, I retry sequentially 2 times and then stop resending.

Meanwhile, I receive this error message in my Global error handler with the same thread ID.

Unhandled rejection Trigger {"reason":{"status":400,"headers":{"alt-svc":"h3=\":443\"; ma=86400","cf-cache-status":"DYNAMIC","cf-ray":"8af38853fc9b641c-SJC","connection":"keep-alive","content-length":"217","content-type":"application/json","date":"Wed, 07 Aug 2024 01:35:53 GMT","openai-organization":"xtravision-ai-0qr74n","openai-processing-ms":"56","openai-version":"2020-10-01","server":"cloudflare","set-cookie":"__cf_bm=xSKJB9.KRWcvNuy28tdPNk6LZ01CinOtA; path=/; expires=Wed, 07-Aug-24 02:05:53 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=I4zFotD6LF5GbCGqaa3I1AifEhf586o-1722994553071-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None","strict-transport-security":"max-age=15552000; includeSubDomains; preload","x-content-type-options":"nosniff","x-request-id":"req_575ca705d2c2d5aa7d2f9e2ef775241e"},"request_id":"req_575ca705d2c2d5aa7d2f9e2ef775241e","error":{"message":"Can't add messages to thread_jfNWRMg0hojEMYDGnQLu6LwO while a run run_dwVhF3Zzwcu9v6KinLjwrc3J is active.","type":"invalid_request_error","param":null,"code":null},"code":null,"param":null,"type":"invalid_request_error"},"promise":{},"isNotifyToAdmin":true,"stack":"Error: Unhandled rejection Trigger\n at process.<anonymous> (/app/build/systemProcessEvent.js:19:49)\n at process.emit (node:events:517:28)\n at process.emit (node:domain:489:12)\n at emit (node:internal/process/promises:149:20)\n at processPromiseRejections (node:internal/process/promises:283:27)\n at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants