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

on('error', () => ...) event does not fire on APIUserAbortError #526

Open
1 task done
petrgazarov opened this issue Nov 22, 2023 · 2 comments
Open
1 task done

on('error', () => ...) event does not fire on APIUserAbortError #526

petrgazarov opened this issue Nov 22, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@petrgazarov
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

From the error event documentation:

The event fired when an error is encountered outside of a parse function or an abort.

However, I found that it is not fired on abort. Instead, the way to gracefully handle an abort seems to be with the finalContent method (there may be other ways, I didn't test). I found this out from looking at the tests.

To Reproduce

This test already has the minimal setup to reproduce. Simply add an assertion to expect emittedError to be present after aborting.

Code snippets

No response

OS

macOS

Node version

20.9.0

Library version

4.18.0

@petrgazarov petrgazarov added the bug Something isn't working label Nov 22, 2023
@rattrayalex
Copy link
Collaborator

Sorry about that. We hope to fix this when we can. In the meantime, you can listen to .on('abort') for this purpose. Does that work well for you?

Out of curiosity, is there a reason you'd like .on('error') to throw on aborts rather than listening to .on('abort') separately, or was it simply because that was what the docs told you to do?

@petrgazarov
Copy link
Author

.on('abort') works fine for my use case, I made this issue before trying it out :).

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