-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Node read stream hangs on specific file, base64 encoding #19862
Comments
Fwiw, this seems to work on |
It will fail If In the following snippet, not even const fs = require('fs');
const invalid = '/tmp/invalid';
fs.writeFileSync(invalid, '1234');
function readFileBase64(filePath) {
const rs = fs.createReadStream(filePath, {
encoding: 'base64',
highWaterMark: 2 // with 3 data is called, but end no
});
rs.on('data', (data) => {
console.log(filePath, 'data', Buffer.from(data, 'base64').toString());
// Nothing for hwm == 2
// 123 for hwm == 3
// 123 & 4 for hwm == 4 == file.length
});
rs.on('end', () => {
console.log(filePath, 'end');
});
rs.on('error', e => {
console.log(filePath, 'error', e);
});
}
readFileBase64(invalid); This works fine on I'm willing to track down the changes on master to fix this issue. |
@addaleax I found the issue, and already solved it for |
cc @nodejs/streams |
I fear this might not be fixable in Node 6, 8, 9 without backporting a semver-major change: #18994 |
Are we planning to backport? |
@antsmartian I would not recommend it, as it could actually break things. |
This is fixed in Node 10, I'm closing this. |
Thanks for the update @mcollina |
I have following code working for every file except the one that keeps hanging without emitting
end
orerror
events (I tried other stream events too).If I move read point with
start
option to 1 instead of 0 it works properly. Same ifhighWaterMark
is set to value other than default. It doesn't really help as it seems it can fail with other "corrupted" file.It seems like Node bug, but maybe there's something I'm missing here.
Here's file to recreate the issue:
http://s3.eu-west-1.amazonaws.com/jjapitest/file
Here's interactive demo of the issue:
https://repl.it/repls/AnimatedDisguisedNumerator
The text was updated successfully, but these errors were encountered: