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

Fixes piping #59

Merged
merged 9 commits into from
Apr 5, 2019
Merged

Fixes piping #59

merged 9 commits into from
Apr 5, 2019

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Apr 3, 2019

There was a timing issue in the way the piping was handled: we were closing the output streams too soon, and that was causing weird race conditions (in Jest it could lead to timeouts, tests reported finished before they actually did, or validation errors within the Node internals). This diff should fix the logic behind it by:

  • Ensuring that the builtin commands always close their stdout/stderr after they're done writing, except if they're the right-most command (because then they might close the real stdout, which would throw an exception).

  • Ensuring that the builtin commands always close their stdin after they're done reading, except if they're the left-most command (for a similar reason but this time with the real stdin).

@arcanis
Copy link
Member Author

arcanis commented Apr 5, 2019

Pfew ... the Windows tests are now passing! I had to rewrite the pipeline handling, since there was something wrong somewhere. Since the child_process API is relatively hard to interlace with user streams I wrote pipe.ts which offers a simple generic interface (start(echo).pipeTo(cat).run()), then modified berry-shell/index.ts to use this API.

There's some refactoring to be done in order to increase the quality of this code (in particular split both the shell and the pipe in different folders, and add more comments detailing the various steps), but it's a significant enough step forward that I feel confident merging this.

@arcanis arcanis merged commit 7d29aae into yarnpkg:master Apr 5, 2019
@arcanis arcanis deleted the weird branch April 5, 2019 16:38
@arcanis
Copy link
Member Author

arcanis commented Apr 5, 2019

Also of note: the unit tests aren't passing with Node 11 (even on OSX/Linux) due to a regression in Node 11.10: nodejs/node#27097

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

Successfully merging this pull request may close these issues.

1 participant