-
Notifications
You must be signed in to change notification settings - Fork 300
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
Chunk size is not always automatically found for fs.ReadStream #454
Comments
Thanks for the detailed report. tus-js-client currently relies on the tus-js-client/lib/node/fileReader.js Line 14 in 14c3634
It is used to get the file size via
Since you get it from an file descriptor, this property is not present and tus-js-client falls back to handling it as any arbitrary readable stream, which requires buffer memory and the I think in theory we could use |
Thanks for the very quick answer ! Indeed maybe |
I do understand that! I am also not sure when I have time to address this. |
Hello, first of all thank you very much for this amazing library and specification, it's very easy to use it and works well! I have found a bug while using this library in a Node.js context.
Describe the bug
The node.js installation doc says that if I pass an instance of
fs.ReadStream
, "no chunk will be held in memory". I took this to mean that I did not have to specify thechunkSize
anduploadSize
options. However, after trying to give it a stream from afs.fileHandle
,tus-js-client
will complain that it needs a finitechunkSize
option. I am not sure if I am misunderstanding and it was always meant to work this way or if this is a case wheretus-js-client
did not correctly recognize what I'm giving it.To Reproduce
I tried hard to setup a shareable reproduction with https://codesandbox.io but I did not succeed. They run Node.js v14 and
filehandle.createReadStream()
was only introduced in Node.js v16. I could not find a "code sandbox" website that allows me to run Node v16. If you know of any, please share it and I'll try to setup a reproduction there.Here is the code I used on codesandbox. It creates a HTTP server on port 8080. When called with any request, it will read a
fixture.json
file (its contents don't matter) and upload it tohttps://tusd.tusdemo.net/files/
. If you comment thechunkSize
oruploadSize
option,tus-js-client
will throw an error explaining that it needs those options.Steps:
index.js
file and paste the code block below into itchunkSize
option inindex.js
tus-js-client
fixture.json
file next toindex.js
and write any JSON in it, for example{"key": "value"}
node index.js
curl localhost:8080
Expected behavior
I expected not to have to set the
chunkSize
anduploadSize
options so thattus-js-client
would deduce them by itself.Setup details
The text was updated successfully, but these errors were encountered: