Skip to content
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

Duplexer confusing example #104

Closed
Rybadour opened this issue Jan 13, 2015 · 8 comments
Closed

Duplexer confusing example #104

Rybadour opened this issue Jan 13, 2015 · 8 comments

Comments

@Rybadour
Copy link

I'd recommend changing the challenge to use anything else but child_process. Seeing stdin and stdout as the arguments can give people false confidence of duplexer. I just spend an hour trying to figure out the next challenge only to find out that the order of duplexer is Writable, Readable. I know the documentation says that but other people made the same mistake: #55

I'd bet it help other people too if this challenge used process.stdin/stdout instead or something like reading from files.

@lyzadanger
Copy link

+1 on this. The confusing element for me here isn't duplexer's argument order necessarily (which are explicitly mentioned in the instructions), but that child_process.stdin is a Writeable stream (as opposed to process.stdin, which is a Readable stream) and child_process.stdout which is likewise flipped from process.stdout. So I struggled for a while with

return duplexer(childProcess.stdout, childProcess.stdin);

Because I didn't realize that child_process flipped the stdin/stdout stream types (not because I didn't grok that the Writeable should come first).

At the very least perhaps a heads up to this little twist in child_process?

@Ryan1729
Copy link

Ryan1729 commented May 3, 2015

I also found myself confused as to why

return duplexer(childProcess.stdout, childProcess.stdin);

didn't work.

@famousgarkin
Copy link

+1

@Sequoia
Copy link
Contributor

Sequoia commented May 20, 2015

the confusion here stems from the following:

  • process.stdin: 📖 Readable stream
  • process.stdout: 📝 Writable stream
  • childProc.stdin: 📝 Writable stream
  • childProc.stdout: 📖 Readable stream

for process you're inside the process to stdin is readable to you, for child process you're outside so that process's stdin is writable to you.

@klarkc
Copy link

klarkc commented Jul 29, 2015

+1 The @Sequoia explanation must be in the documentation.

@mganuci
Copy link

mganuci commented Jan 12, 2016

Thank you @Sequoia for the explanation, I got confused as well. However, even the reference solution doesn't work due to a unit test failing

not ok 3 should be equal
  ---
    operator: equal
    expected:
      'ihrl\nibza\nipzjbpa\nillasl\nillasl\nihghhy\nivvw\nillw\nillw\nibza\nibn\
nilla\nifghuapul\nive'
    actual:
      'ihrl\nibza'
  ...

@kalinchernev
Copy link
Member

Nice discussion, definitely worth having the explanation from @Sequoia in the exercise to be accessible to anyone going through the problem. Opened a PR to include these additions in the hints.

@ccarruitero
Copy link
Contributor

Closing since changes was added in #196

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

No branches or pull requests

9 participants