client-js icon indicating copy to clipboard operation
client-js copied to clipboard

Error responses partially processed as successful responses

Open bradjones1 opened this issue 1 year ago • 1 comments

Describe the bug

While working on bubbling up more contextual data about error conditions (mostly on the HTTP transport) I discovered that error responses are being handled as successful, and then rejected as part of that processing. This (I think) is a result of how batches are handled. However, when handling a standalone response object, this resulted in not being able to directly catch the rejection, as well as the result event being emitted, if you are using the event emitter.

To Reproduce Steps to reproduce the behavior:

  1. Request a method that results in an error response.
  2. Witness it is processed as a response, and then rejected.

Expected behavior The response should be handled as an error at the outset.

Desktop (please complete the following information):

  • OS: Linux, Android and iOS
  • Browser: Firefox
  • Version 109.0.1

Additional context This is fixed as part of my overall error handling improvements on https://github.com/open-rpc/client-js/pull/307

bradjones1 avatar Mar 21 '23 17:03 bradjones1

This is specifically the changes at https://github.com/open-rpc/client-js/pull/307/files#r1143791280

bradjones1 avatar Mar 21 '23 17:03 bradjones1