From 219daf719ed7eecd22126d66364ee869b85a49ef Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Thu, 24 Mar 2022 11:08:05 -0700 Subject: [PATCH 1/2] misc: set encoding on streams for unicode correctness --- .../test/smokehouse/lighthouse-runners/devtools.js | 10 ++++++---- lighthouse-core/gather/connections/cri.js | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js b/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js index 839fd4de394c..748ba4b24c5a 100644 --- a/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +++ b/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js @@ -33,13 +33,15 @@ async function spawnAndLog(command, args) { else reject(new Error(`Command exited with code ${code}`)); }); spawnHandle.on('error', reject); + spawnHandle.stdout.setEncoding('utf8'); spawnHandle.stdout.on('data', data => { - console.log(data.toString()); - log += `STDOUT: ${data.toString()}`; + console.log(data); + log += `STDOUT: ${data}`; }); + spawnHandle.stderr.setEncoding('utf8'); spawnHandle.stderr.on('data', data => { - console.log(data.toString()); - log += `STDERR: ${data.toString()}`; + console.log(data); + log += `STDERR: ${data}`; }); }); await promise; diff --git a/lighthouse-core/gather/connections/cri.js b/lighthouse-core/gather/connections/cri.js index 42e877b33d88..ab5168c621e8 100644 --- a/lighthouse-core/gather/connections/cri.js +++ b/lighthouse-core/gather/connections/cri.js @@ -88,6 +88,7 @@ class CriConnection extends Connection { path: '/json/' + command, }, response => { let data = ''; + response.setEncoding('utf8'); response.on('data', chunk => { data += chunk; }); From b34a52c572271ce248eccf1a709eb3d86d069ad8 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Wed, 30 Mar 2022 16:45:01 -0700 Subject: [PATCH 2/2] edit --- lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js b/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js index 855d3fb17afc..c5729b0b6b08 100644 --- a/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +++ b/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js @@ -46,7 +46,7 @@ async function spawnAndLog(logs, command, args) { spawnHandle.stderr.setEncoding('utf8'); spawnHandle.stderr.on('data', data => { process.stderr.write(data); - logs.push(`STDERR: ${data.toString()}`); + logs.push(`STDERR: ${data}`); }); }); await promise;