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

Incorrect error thrown on invalid statusCode #3950

Closed
paucabuti opened this issue Dec 16, 2024 · 3 comments
Closed

Incorrect error thrown on invalid statusCode #3950

paucabuti opened this issue Dec 16, 2024 · 3 comments
Labels
bug Something isn't working Types Changes related to the TypeScript definitions

Comments

@paucabuti
Copy link

Bug Description

The current implementation of undici version 7.1.0 throws a ResponseError object type when a request fails with a statusCode greater than 400. However, the TypeScript types do not include a definition for ResponseError.

Additionally, there is a ResponseStatusCodeError type defined in the TypeScript types, which seems to be intended for such scenarios. This creates an inconsistency, as the code throws ResponseError while the typings suggest ResponseStatusCodeError should be used.

Reproducible By

  1. Make a request that returns a statusCode > 400.
  2. Observe that the error thrown is a ResponseError with UND_ERR_RESPONSE code , which is not part of the TypeScript definitions.

Expected Behavior

The error thrown when a request fails with statusCode > 400 should either:

  • Be updated to throw a ResponseStatusCodeError, matching the TypeScript definitions.
  • Have the missing ResponseError type reintroduced in the TypeScript definitions, if it is the intended behavior.
@paucabuti paucabuti added the bug Something isn't working label Dec 16, 2024
@metcoder95 metcoder95 added the Types Changes related to the TypeScript definitions label Dec 17, 2024
@metcoder95
Copy link
Member

Thanks for the report! Would you like to send a PR for that?

@dancastillo
Copy link
Contributor

Looks to be solved in #3964

@paucabuti
Copy link
Author

Looks to be solved in #3964

Only partially, and not in the right direction. The ResponseError is only being used in response error interceptor. Instead of creating the type, it might be better to address the root issue, eliminate ResponseError (if it’s confirmed that it’s only used there), and move to using specific errors (such as ResponseStatusCodeError in this case).

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

No branches or pull requests

4 participants