storyblok / storyblok-js-client

Universal JavaScript client for Storyblok's API
MIT License
125 stars 86 forks source link

Provide a reason when aborting a request due to timeout #826

Open dovca opened 3 months ago

dovca commented 3 months ago

Expected Behavior

When the storyblok client aborts a request on timeout, a reason should be provided to allow for better logging and debugging. The current default of "AbortError: The operation was aborted." does not provide enough useful context.

Minimal viable solution:

Abort with a reason object providing the request params (url, method, ...), preferably as an instance of some TimeoutError class which can be easily identified in user code.

Ideal solution:

Allow users to define an optional factory function for timeout abort reasons.

Current Behavior

The client aborts a request without an explicit reason.

Steps to Reproduce

  1. Create a new client instance with a specified timeout
  2. Execute a request wrapped in try/catch
  3. When the request is aborted, a generic error is passed into catch block
jonathanribas commented 3 months ago

We have same issue on our side, already opened ticket to Storyblok support and they don't see those timeouts...