box-node-sdk
box-node-sdk copied to clipboard
client.files.getReadStream gets stuck when data is not immediately read
- [x] I have checked that the SDK documentation doesn't solve my issue.
- [x] I have checked that the API documentation doesn't solve my issue.
- [x] I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
- [x] I have searched Issues in this repo and my issue isn't already reported.
Description of the Issue
When data is not read synchronously from the read stream returned from client.files.getReadStream
, the data is never provided and the stream is not closed.
The issue was already reported in #704, but was not resolved. It is still an issue, and hopefully our examples/workarounds can provide some additional insight.
Steps to Reproduce
const sdkInstance = BoxSDK.getPreconfiguredInstance(config);
const client = sdkInstance.getAppAuthClient('enterprise');
const fileStream = await client.files.getReadStream(fileId);
setTimeout(() => {
// data never loads!
fileStream.pipe(process.stdout);
}, 1000);
We were able to workaround this issue by adding in a Passthrough
that doesn't do anything.
const sdkInstance = BoxSDK.getPreconfiguredInstance(config);
const client = sdkInstance.getAppAuthClient('enterprise');
const fileStream = await client.files.getReadStream(fileId);
const passThrough = new PassThrough();
fileStream.pipe(passThrough);
setTimeout(() => {
// data loads!
passThrough.pipe(process.stdout);
}, 1000);
Expected Behavior
Data is never made available on the stream, if the first read from the stream occurs asynchronously.
Error Message, Including Stack Trace
Screenshots
Versions Used
Node SDK: 2.5.0, 2.6.0
Hi @bskiff,
Thanks for your insights!
I've created a jira ticket for my team (jira-2645
), so we can look into this soon.
@arjankowski
This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed.
Hi @bskiff,
We have just fixed this issue using PassThrough
, and it will be available in the next Box Node SDK release.
Thank you for your solution, and if you have any other problem, feel free to let us know.
Regards, Minh
Thanks @congminh1254!
Hi @bskiff ,
We did a release contains your bug fix, you can use Node SDK 2.8.1 to verify if it works for you.
Regards, Minh
We pulled in the new version, and it's working! Thanks again @congminh1254!