You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect error thrown on invalid statusCode #3950
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
Make a request that returns a statusCode > 400.
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.
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).
Activity
metcoder95 commentedon Dec 17, 2024
Thanks for the report! Would you like to send a PR for that?
dancastillo commentedon Dec 28, 2024
Looks to be solved in #3964
paucabuti commentedon Jan 9, 2025
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).