Skip to content

Node read stream hangs on specific file, base64 encoding #19862

Closed
@jan-j

Description

@jan-j
  • Version: 7.9.0/8.9.3/9.7.1
  • Platform: Windows/Linux/MacOS

I have following code working for every file except the one that keeps hanging without emitting end or error events (I tried other stream events too).

const fs = require('fs');

const rs = fs.createReadStream(filePath, {
    encoding: 'base64',
});

rs.on('data', () => {
    console.log('data');
});
rs.on('end', () => {
    console.log('end');
});
rs.on('error', e => {
    console.log('error', e);
});

If I move read point with start option to 1 instead of 0 it works properly. Same if highWaterMark 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions