-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support for different runtimes #199
Comments
In order to support all these platforms with upload progress we could either: Make our own abstraction above fetch and XMLHttpRequest (fetch is needed for Node.js and React Native, XMLHttpRequest is needed for upload progress). Use a library: The only popular library that I can find that satisfies all of these is the good ol'
Alternatively just use |
It's possible to get upload progress using the Fetch API by jumping through a few hoops: https://x.com/vvoyer/status/1856287377188368449 At some point Fetch will get native support for upload progress, but not soon: whatwg/fetch#607 |
afaik this is what i mentioned above, that this workaround only works for chrome, and the only alternative that works cross-browser is XMLHttprequest |
You're right, thanks! I didn't know this but the tweet also means the lacking support in Firefox and Safari. That's unfortunate. Upload progress is an important components for good user experience and ensuring its always available is also a hassle in tus-js-client. |
Yup. If we want to support all these platforms (or specifically node.js+browser) and support upload progress, I think it boils down to that we have to either:
|
Looks like 2 is exactly what Vincent Voier (twitter/vercel) is doing: inspired by axios, he created a tiny wrapper which uses fetch if the client supports upload progress over fetch, then falls back to xhr if not:
|
At some point, I tried using Axios to get upload progress, but it didn't work if I passed it the upload data as one big buffer. A workaround would have been to stream the buffer into Axios, but that's more cumbersome. That being said, I am wondering if upload progress is a concern in the Node SDK itself. Isn't the uploading of files deferred to tus-js-client nowadays? If so, we have to think about upload progress in tus-js-client. That would likely be a similar discussion, but Node SDK could already move to the Fetch API and we just have to figure out how to make tus-js-client compatible with these platforms while still offering upload progress. Does that make sense to you? |
That's a good point. tus-js-client is being used by node-sdk iff Line 175 in 3c0ef2e
like you said, if we remove the option it will allow us to only use tus-js-client for uploads, and thus we can use only fetch because we don't need any upload progress in node-sdk. wdyt @kvz can we remove the deprecated |
Ah great idea to bundle that removal in the next major, just in time! I think we should also bundle the robot types in the major @remcohaszing, we’re so close 🤞 |
For example:
And maybe even
We should then rename the node-sdk to
@transloadit/client
perhaps. Optionally we can support different runtimes with named exports likeimport { BunClient } from '@transloadit/client'
or similar.The text was updated successfully, but these errors were encountered: