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

Running lifecycle scripts might hang on Windows #2462

Closed
segrey opened this issue Jan 16, 2017 · 1 comment
Closed

Running lifecycle scripts might hang on Windows #2462

segrey opened this issue Jan 16, 2017 · 1 comment

Comments

@segrey
Copy link

segrey commented Jan 16, 2017

Do you want to request a feature or report a bug?
Bug

What is the current behavior?

A lifecycle script run by yarn might hang on Windows if the script accesses process.stdin.

If the current behavior is a bug, please provide the steps to reproduce.

Let's consider the example project:

// starter.js
const exec = require('child_process').exec;
var yarn = exec('yarn run app');

yarn.stdout.on('data', function(data) {
    process.stdout.write('yarn: ' + data);
});

yarn.stderr.on('data', function(data) {
    process.stdout.write('yarn: ' + data);
});

yarn.on('close', function(code) {
    process.stdout.write('yarn process finished with exit code ' + code);
});
// package.json
{
  "scripts": {
    "app": "node child.js"
  }
}
// child.js
console.log('child: accessing process.stdin');
console.log('child: done successfully ' + process.stdin);

Sometimes running node starter.js in cmd.exe results in printing these lines and hanging

yarn: yarn: yarn run v0.18.1
yarn: yarn: $ node child.js 
yarn: child: accessing process.stdin

What is the expected behavior?

node starter.js should print these lines and exit

yarn: yarn: yarn run v0.18.1
yarn: yarn: $ node child.js 
yarn: child: accessing process.stdin
yarn: child: done successfully [object Object]
yarn: yarn: Done in 0.17s.
yarn process finished with exit code 0

Please mention your node.js, yarn and operating system version.
yarn 0.18.1, 0.19.0
node 7.4.0
OS Windows 10

Though it's a node.js bug (nodejs/node#10836), it'd be nice if yarn could omit accessing process.stdin entirely when running any lifecycle script. That would fix this issue as well. Currently, process.stdin is accessed in lib/reporters/base-reporter.js (https://github.com/yarnpkg/yarn/blob/v0.20.0-0/src/reporters/base-reporter.js#L55), but not used afterwards.

@rally25rs
Copy link
Contributor

Closing this as it is a Node/Win issue.

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

No branches or pull requests

2 participants