tus / tus-js-client

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

Test with Bun and Deno #692

Open Acconut opened 5 months ago

Acconut commented 5 months ago

In theory, Bun and Deno are somewhat compatible with Node.js runtime. We should test if tus-js-client runs in those environment, and if so, update the documentation and preferable integrate them into our CI setup.

n-kort commented 5 months ago

I was trying this in Deno (via the Vimeo sdk) and it did not work. No errors or warnings, the files are created but the upload does not proceed (one 'progress' event is fired before it hangs).

Trying it out directly and I got a little further, although I had to use the browser versions for this, and polyfill XMLHttpRequest.

import 'jsr:/@kitsonk/xhr'
import tus from 'npm:tus-js-client/lib.es5/browser/index.js'

Using the test tusdemo endpoint I managed to get it working, with Blob files.

Bun probably should work with the node-specific scripts (Buffer being the main one that doesn't work the same in Deno). I did not try yet though.

Acconut commented 5 months ago

No errors or warnings, the files are created but the upload does not proceed (one 'progress' event is fired before it hangs).

Interesting, what exactly do you mean by "files are created"? As far as I know, the Vimeo API does not support upload creation via the tus protocol.

Trying it out directly and I got a little further, although I had to use the browser versions for this, and polyfill XMLHttpRequest.

Yes, XMLHttpRequest is not available in Node.js, Bun and Deno. Ideally we would also include a fallback to fetch if that is available instead.

Thank you for reporting!

Acconut commented 5 months ago

One thing worth mentioning is that the Fetch API does not support upload progress like XHR does: https://stackoverflow.com/questions/35711724/upload-progress-indicators-for-fetch