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

fix(output): ignore stdio channels (stdout, stdin, stderr) #121

Merged
merged 2 commits into from
Sep 17, 2018

Conversation

wardpeet
Copy link
Contributor

@wardpeet wardpeet commented Sep 9, 2018

Add { stdio: 'ignore' } to execFileSync to make sure no output is generated to our output buffers.

fixes GoogleChrome/lighthouse#5795

@wardpeet
Copy link
Contributor Author

@paulirish whenever you have the time 😄

@paulirish
Copy link
Member

tbh i can't reproduce the bug on mac or my ubuntu, but i don't see why this wouldn't work.

@wardpeet did you repro it?

@paulirish paulirish merged commit 35842ba into GoogleChrome:master Sep 17, 2018
@wardpeet
Copy link
Contributor Author

yes I did but only in docker so I guess it has to do with docker piping all output to the docker logs command

@ghost
Copy link

ghost commented Sep 25, 2018

The modified line tries to parse the output of the executed command. { stdio: 'ignore' } redirects the output to /dev/null, completely breaking that.

@wardpeet
Copy link
Contributor Author

Sorry what are you referring to? What does it break?

@ghost
Copy link

ghost commented Sep 25, 2018

The line modified by the commit 35842ba:
execFileSync('which', [executable], {stdio: 'ignore'}).toString().split(newLineRegex)[0];

.toString() can't return anything if stdout is ignored.

@wardpeet
Copy link
Contributor Author

I'll create a fix

@paulirish
Copy link
Member

aye. just tested this and looks like @vpracht is right. Thx very much for commenting!

my repro:

// log.js
process.stdout.write('STDOUT\n');

process.stderr.write('stderr\n');
// index.js
const {execFileSync} = require('child_process');

const output = execFileSync('node', ['log.js'], {encoding: 'utf-8', stdio: 'ignore'});

console.log({output});
node index.js
# { output: null }

@wardpeet looks like 'stdio':'pipe' is what we want? also i don't know how this worked without utf-8 before, but it seems necessary to avoid getting a buffer.

@wardpeet
Copy link
Contributor Author

yeah I just tested it in docker too and pipe works as well. The reason why I thought it wouldn't was because I thought the default was pipe as stated in the docs but I missed the following line

Child's stdio configuration. stderr by default will be output to the parent process' stderr unless stdio is specified. Default: 'pipe'.

@wardpeet
Copy link
Contributor Author

@vpracht fix is up #125

@paulirish
Copy link
Member

fixed in chrome-launcher@0.10.5

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.

Passing --quiet still outputs which failure to stdout
2 participants