Skip to content

Commit

Permalink
fix(launcher): make dumpio and pipe options work together (#4727)
Browse files Browse the repository at this point in the history
Don't ignore stdout and stderr when using pipe for remote debugging and dumpio is true. In that case puppeteer process connects to the stdout/stderr streams of the child process and it will not hang.
  • Loading branch information
yury-s authored and aslushnikov committed Jul 18, 2019
1 parent 3982a60 commit 2abaac1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Launcher.js
Expand Up @@ -123,7 +123,13 @@ class Launcher {

const usePipe = chromeArguments.includes('--remote-debugging-pipe');
/** @type {!Array<"ignore"|"pipe">} */
const stdio = usePipe ? ['ignore', 'ignore', 'ignore', 'pipe', 'pipe'] : ['pipe', 'pipe', 'pipe'];
let stdio = ['pipe', 'pipe', 'pipe'];
if (usePipe) {
if (dumpio)
stdio = ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'];
else
stdio = ['ignore', 'ignore', 'ignore', 'pipe', 'pipe'];
}
const chromeProcess = childProcess.spawn(
chromeExecutable,
chromeArguments,
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures.spec.js
Expand Up @@ -22,6 +22,16 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;

describe('Fixtures', function() {
it_fails_ffox('dumpio option should work with pipe option ', async({server}) => {
let dumpioData = '';
const {spawn} = require('child_process');
const options = Object.assign({}, defaultBrowserOptions, {pipe: true, dumpio: true});
const res = spawn('node',
[path.join(__dirname, 'fixtures', 'dumpio.js'), puppeteerPath, JSON.stringify(options)]);
res.stderr.on('data', data => dumpioData += data.toString('utf8'));
await new Promise(resolve => res.on('close', resolve));
expect(dumpioData).toContain('message from dumpio');
});
it('should dump browser process stderr', async({server}) => {
let dumpioData = '';
const {spawn} = require('child_process');
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/dumpio.js
Expand Up @@ -2,6 +2,7 @@
const [, , puppeteerRoot, options] = process.argv;
const browser = await require(puppeteerRoot).launch(JSON.parse(options));
const page = await browser.newPage();
await page.evaluate(() => console.error('message from dumpio'));
await page.close();
await browser.close();
})();

0 comments on commit 2abaac1

Please sign in to comment.