Skip to content

Emit errors when request is aborted #778

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Emit errors when request is aborted #778

wants to merge 1 commit into from

Conversation

Acconut
Copy link
Member

@Acconut Acconut commented Jun 13, 2025

While working on #775, we discovered that not every HTTP stack in tus-js-client behaves the same way when aborting requests:

  • XHRHttpStack just leaves the promise returned by send hanging, neither resolving nor rejecting it.
  • NodeHttpStack threw a network-related error (usually ECONNRESET).
  • FetchHttpStack threw a DOMException.

While the exact error is not important, it's helpful to standardize on throwing some error, as allows for simpler logic when aborting requests. Hence this PR, which implements this. It uses a DOMException since normal Error instances in JavaScript don't have proper error codes. While DOMException is a Web API, I think it's available in most JavaScript runtimes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant