Skip to content

Piping from stdin is broken #5927

Description

@addaleax
  • Version: master (ace1009 and upwards, everything before is fine)
  • Platform: Linux 4.2.0-34-generic Gitter chat room? #39-Ubuntu SMP Thu Mar 10 22:13:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: stream

Since ace1009 (#5776), stdin is truncated to the first 64kb when piped to some other stream.

Before:

$ head -c 256000 /dev/zero | ./node -e 'process.stdin.pipe(process.stdout)' | wc
      0       0  256000

After:

$ head -c 256000 /dev/zero | ./node -e 'process.stdin.pipe(process.stdout)' | wc
      0       0   65536

This also goes for piping to bl(), and the end event on process.stdin seems to be fired only when the input is smaller than 16384 bytes.

/cc @orangemocha

Activity

  1. added
    streamIssues and PRs related to Node.js streams.
    processIssues and PRs related to the process subsystem.
    on Mar 27, 2016
  2. addaleax commented on Mar 27, 2016

    @addaleax
    MemberAuthor

    Btw, apparently this only happens with pipes, i.e.

    $ head -c 256000 /dev/zero > data
    $ ./node -e 'process.stdin.pipe(process.stdout)' < data | wc
          0       0  256000

    works just fine.

  3. Fishrock123 commented on Mar 27, 2016

    @Fishrock123
    Contributor

    cc @nodejs/streams

  4. Fishrock123 commented on Mar 27, 2016

    @Fishrock123
    Contributor

    Why it only happens with pipes probably has something to do with what I just posted in #5916 (comment):

    <-ing a file into stdin actually results in a fs.ReadStream, rather an a tty.ReadStream, and as such does not inherit from net.Socket, unlike the other possible stdin options:

    case 'FILE':
    var fs = require('fs');
    stdin = new fs.ReadStream(null, { fd: fd, autoClose: false });
    break;

  5. addaleax commented on Mar 27, 2016

    @addaleax
    MemberAuthor

    @Fishrock123 Makes sense then, thanks for the info!

  6. orangemocha commented on Mar 29, 2016

    @orangemocha
    Contributor

    I will definitely follow up and investigate this, but it might take me a while to fix it.. streams is delicate code, and I am travelling to the VM summit in SF next week. I might end up reverting #5776 while I figure it out, as it seems that this issue is more severe.

    Of course, if anyone wants to investigate further please be welcome! As a first step I'd like to see if reverting 4611389 (but not ace1009) makes this problem go away or not.

  7. 7 remaining items

  8. MylesBorins commented on Apr 11, 2016

    @MylesBorins
    Contributor

    @orangemocha I've tried reapplying ace1009 to master and running CI to see if the suite passes on windows https://ci.nodejs.org/job/node-test-commit/2887/

    edit: no bueno

  9. orangemocha commented on Apr 13, 2016

    @orangemocha
    Contributor

    Thanks @thealphanerd . I am investigating again, teaming up with @joaocgreis and @bzoz, and we have also confirmed that emitting 'pause' on nextTick alone causes this issue.

    This is unfortunate, because in some of my testing to fix #5384 I could see 'pause' and 'resume' events being emitted out of order. I have a bad feeling that there might be another set of hidden bugs in Node because of that, but that they are not getting caught by our unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    processIssues and PRs related to the process subsystem.streamIssues and PRs related to Node.js streams.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions