tus / tus-js-client

A pure JavaScript client for the tus resumable upload protocol
https://tus.io/
MIT License
2.11k stars 316 forks source link

HttpRequest.setHeader is being called with an incorrect parameter type, number insted of string #708

Closed DraganDanicic closed 1 month ago

DraganDanicic commented 2 months ago

Describe the bug In my implementation of the HttpRequest interface, the setHeader(header, value) method is being called with a number as the second parameter. This disrupts the logic of Angular's HttpClient, which I've used as the request handler.

To Reproduce

  1. Implement HtttpRequest with Angular's HtttpClient,
  2. also implement HttpStack and initialise it using the instance from step 1
  3. Instance from step 2 to should be passed to tus.Upload constructor as httpStack option
  4. Try now uploading a file with tus.Upload instance
  5. File upload will fail with TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a.....
  6. Error is thrown by Angular's http.mjs script because it can not process number value
Screenshot 2024-08-23 at 12 30 09

Expected behavior Function call of HttpRequest.setHeader should receive string as second argument as per defintion of method in interface.

Setup details

Acconut commented 2 months ago

Thanks for bringing this up. I just saw that you already started working on a PR: https://github.com/tus/tus-js-client/pull/709 Thank you very much for this!

Acconut commented 1 month ago

This is fixed in the 4.2.0 release.