From 62f6fa23fc78cb7fb8a4124f52698d0607e7ddb6 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Wed, 19 Jul 2023 12:38:41 -0700 Subject: [PATCH 1/9] misc: drop node 16 support --- .github/workflows/ci.yml | 4 ++-- .github/workflows/cron-weekly.yml | 4 ++-- .github/workflows/devtools.yml | 12 ++++++------ .github/workflows/package-test.yml | 4 ++-- .github/workflows/publish.yml | 2 +- .github/workflows/smoke.yml | 8 ++++---- .github/workflows/unit.yml | 6 +++--- docs/headless-chrome.md | 8 ++++---- package.json | 2 +- readme.md | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 472eaed57cb2..15acf16a54a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,10 +28,10 @@ jobs: GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }} - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - run: yarn install --frozen-lockfile --network-timeout 1000000 - run: yarn type-check diff --git a/.github/workflows/cron-weekly.yml b/.github/workflows/cron-weekly.yml index 369b00bbc9fe..397608f1eade 100644 --- a/.github/workflows/cron-weekly.yml +++ b/.github/workflows/cron-weekly.yml @@ -31,10 +31,10 @@ jobs: steps: - name: git clone uses: actions/checkout@v2 - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - run: yarn --frozen-lockfile - run: yarn mocha --testMatch=third-party/chromium-synchronization/*-test.js diff --git a/.github/workflows/devtools.yml b/.github/workflows/devtools.yml index 9da2a2671c7c..76a05b0b1c21 100644 --- a/.github/workflows/devtools.yml +++ b/.github/workflows/devtools.yml @@ -25,10 +25,10 @@ jobs: with: path: lighthouse - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - name: Generate cache hash run: bash $GITHUB_WORKSPACE/lighthouse/.github/scripts/generate-devtools-hash.sh > cdt-test-hash.txt @@ -91,10 +91,10 @@ jobs: with: path: lighthouse - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - run: yarn --frozen-lockfile --network-timeout 1000000 working-directory: ${{ github.workspace }}/lighthouse @@ -136,10 +136,10 @@ jobs: with: path: lighthouse - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - name: Load build artifacts id: devtools-build-artifacts diff --git a/.github/workflows/package-test.yml b/.github/workflows/package-test.yml index e2556f3456b7..b81120a0b044 100644 --- a/.github/workflows/package-test.yml +++ b/.github/workflows/package-test.yml @@ -19,10 +19,10 @@ jobs: - name: git clone uses: actions/checkout@v2 - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - run: yarn install --frozen-lockfile --network-timeout 1000000 - run: yarn build-report diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index be8eb6db86f0..7a61f2134ac6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x registry-url: https://registry.npmjs.org/ - run: yarn --frozen-lockfile diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 1cf152dd94dc..0550a28f52c8 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -35,10 +35,10 @@ jobs: # Depth of at least 2 for codecov coverage diffs. See https://github.com/GoogleChrome/lighthouse/pull/12079 fetch-depth: 2 - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - name: Define ToT chrome path if: matrix.chrome-channel == 'ToT' @@ -138,10 +138,10 @@ jobs: - name: git clone uses: actions/checkout@v2 - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - run: yarn install --frozen-lockfile --network-timeout 1000000 - run: yarn build-report diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index c0a16ecad219..c14541c29bce 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -13,7 +13,7 @@ jobs: unit: strategy: matrix: - node: ['16', '18'] + node: ['18', '20'] fail-fast: false runs-on: ubuntu-latest name: node ${{ matrix.node }} @@ -93,10 +93,10 @@ jobs: - name: git clone uses: actions/checkout@v2 - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: 16.x + node-version: 18.x - run: yarn install --frozen-lockfile --network-timeout 1000000 - run: yarn build-report diff --git a/docs/headless-chrome.md b/docs/headless-chrome.md index e0166211ad3d..f1b4ced26d1e 100644 --- a/docs/headless-chrome.md +++ b/docs/headless-chrome.md @@ -5,8 +5,8 @@ Setup: ```sh -# Lighthouse requires Node 16 LTS (16.x) or later. -curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\ +# Lighthouse requires Node 18 LTS (18.x) or later. +curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\ sudo apt-get install -y nodejs npm # get chromium (stable) @@ -27,8 +27,8 @@ lighthouse --chrome-flags="--headless" https://github.com Alternatively, you can run full Chrome + xvfb instead of headless mode. These steps worked on Debian Jessie: ```sh -# get node 16 -curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - +# get node 18 +curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs npm # get chromium (stable) and Xvfb diff --git a/package.json b/package.json index 8dd545780db6..896fa1c1ca22 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "smokehouse": "./cli/test/smokehouse/frontends/smokehouse-bin.js" }, "engines": { - "node": ">=16.16" + "node": ">=18" }, "scripts": { "prepack": "yarn build-report --standalone --flow --esm && yarn build-types", diff --git a/readme.md b/readme.md index 1788ea000d94..36f17e06909a 100644 --- a/readme.md +++ b/readme.md @@ -52,7 +52,7 @@ The Chrome extension was available prior to Lighthouse being available in Chrome The Node CLI provides the most flexibility in how Lighthouse runs can be configured and reported. Users who want more advanced usage, or want to run Lighthouse in an automated fashion should use the Node CLI. -_Lighthouse requires Node 16 LTS (16.x) or later._ +_Lighthouse requires Node 18 LTS (18.x) or later._ **Installation**: From 1ada62abae6c8a3db61558673094d96f2835654f Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Wed, 19 Jul 2023 15:57:31 -0700 Subject: [PATCH 2/9] fix bundle --- cli/test/smokehouse/lighthouse-runners/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/test/smokehouse/lighthouse-runners/bundle.js b/cli/test/smokehouse/lighthouse-runners/bundle.js index cae36da0bf8e..015910822765 100644 --- a/cli/test/smokehouse/lighthouse-runners/bundle.js +++ b/cli/test/smokehouse/lighthouse-runners/bundle.js @@ -82,7 +82,7 @@ async function runBundledLighthouse(url, config, testRunnerOptions) { const logLevel = testRunnerOptions.isDebug ? 'verbose' : 'info'; // Puppeteer is not included in the bundle, we must create the page here. - const browser = await puppeteer.connect({browserURL: `http://localhost:${port}`}); + const browser = await puppeteer.connect({browserURL: `http://127.0.0.1:${port}`}); const page = await browser.newPage(); const runnerResult = await lighthouse(url, {port, logLevel}, config, page); if (!runnerResult) throw new Error('No runnerResult'); From f8a9b5dbfaf06d7572f02448305639d889a7ad3a Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Wed, 19 Jul 2023 16:15:00 -0700 Subject: [PATCH 3/9] new testdouble --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 896fa1c1ca22..0a5fbd2d386f 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,7 @@ "rollup-plugin-polyfill-node": "^0.12.0", "tabulator-tables": "^4.9.3", "terser": "^5.18.2", - "testdouble": "^3.17.2", + "testdouble": "^3.18.0", "typed-query-selector": "^2.6.1", "typescript": "^5.0.4", "wait-for-expect": "^3.0.2", diff --git a/yarn.lock b/yarn.lock index 8b55a773a886..52d7466ad8cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6001,10 +6001,10 @@ queue-tick@^1.0.1: resolved "https://registry.yarnpkg.com/queue-tick/-/queue-tick-1.0.1.tgz#f6f07ac82c1fd60f82e098b417a80e52f1f4c142" integrity sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag== -quibble@^0.6.17: - version "0.6.17" - resolved "https://registry.yarnpkg.com/quibble/-/quibble-0.6.17.tgz#1c47d40c4ee670fc1a5a4277ee792ca6eec8f4ca" - integrity sha512-uybGnGrx1hAhBCmzmVny+ycKaS5F71+q+iWVzbf8x/HyeEMDGeiQFVjWl1zhi4rwfTHa05+/NIExC4L5YRNPjQ== +quibble@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/quibble/-/quibble-0.7.0.tgz#fd7f7f03ed4c2682b55523433af5e66bc26bde9f" + integrity sha512-uiqtYLo6p6vWR/G3Ltsg0NU1xw43RcNGadYP+d/DF3zLQTyOt8uC7L2mmcJ97au1QE1YdmCD+HVIIq/RGtkbWA== dependencies: lodash "^4.17.21" resolve "^1.22.1" @@ -6827,13 +6827,13 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" -testdouble@^3.17.2: - version "3.17.2" - resolved "https://registry.yarnpkg.com/testdouble/-/testdouble-3.17.2.tgz#a7d624c2040453580b4a636b3f017bf183a8f487" - integrity sha512-oRrk1DJISNoFr3aaczIqrrhkOUQ26BsXN3SopYT/U0GTvk9hlKPCEbd9R2uxkcufKZgEfo9D1JAB4CJrjHE9cw== +testdouble@^3.18.0: + version "3.18.0" + resolved "https://registry.yarnpkg.com/testdouble/-/testdouble-3.18.0.tgz#850a04d00045a52cd08c99cb69aea6845fe86587" + integrity sha512-awRay/WxNHYz0SJrjvvg1xE4QQkbKgWFN1VNhhb132JSO2FSWUW4cebUtD0HjWWwrvpN3uFsVeaUhwpmVlzlkg== dependencies: lodash "^4.17.21" - quibble "^0.6.17" + quibble "^0.7.0" stringify-object-es5 "^2.5.0" theredoc "^1.0.0" From f3a96aaf2f4436a9907d94cdff87a85e93750830 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Wed, 19 Jul 2023 16:34:47 -0700 Subject: [PATCH 4/9] fix 18 --- core/test/config/config-helpers-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/test/config/config-helpers-test.js b/core/test/config/config-helpers-test.js index ab5ec6ecf85b..e40d71a971d0 100644 --- a/core/test/config/config-helpers-test.js +++ b/core/test/config/config-helpers-test.js @@ -424,7 +424,7 @@ describe('.resolveGathererToDefn', () => { it('throws but not for missing gatherer when it has a node dependency error', async () => { const resultPromise = resolveGathererToDefn('../fixtures/invalid-gatherers/require-error.js', [], moduleDir); - await expect(resultPromise).rejects.toThrow(/Cannot find module/); + await expect(resultPromise).rejects.toThrow(/no such file or directory/); }); }); @@ -502,7 +502,7 @@ describe('.resolveAuditsToDefns', () => { const resultPromise = resolveAuditsToDefns([ '../fixtures/invalid-audits/require-error.js', ], moduleDir); - await expect(resultPromise).rejects.toThrow(/Cannot find module/); + await expect(resultPromise).rejects.toThrow(/no such file or directory/); }); }); From f68b34e6ae0864fcb550480d81d116037126e63b Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Wed, 19 Jul 2023 16:52:52 -0700 Subject: [PATCH 5/9] fix source maps --- core/test/gather/gatherers/source-maps-test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/test/gather/gatherers/source-maps-test.js b/core/test/gather/gatherers/source-maps-test.js index 3a8bcd3184d8..616b79a11b19 100644 --- a/core/test/gather/gatherers/source-maps-test.js +++ b/core/test/gather/gatherers/source-maps-test.js @@ -256,13 +256,17 @@ describe('SourceMaps gatherer', () => { { scriptUrl: mapsAndEvents[0].scriptParsedEvent.url, sourceMapUrl: mapsAndEvents[0].scriptParsedEvent.sourceMapURL, - errorMessage: 'SyntaxError: Unexpected token { in JSON at position 1', + // This message was changed in Node 20, check for old and new versions. + // eslint-disable-next-line max-len + errorMessage: expect.stringMatching(/(Expected property name|Unexpected token).*at position 1/), map: undefined, }, { scriptUrl: mapsAndEvents[1].scriptParsedEvent.url, sourceMapUrl: undefined, - errorMessage: 'SyntaxError: Unexpected token ; in JSON at position 2', + // This message was changed in Node 20, check for old and new versions. + // eslint-disable-next-line max-len + errorMessage: expect.stringMatching(/(Unexpected non-whitespace|Unexpected token).*at position 2/), map: undefined, }, ]); From 231957c00fb8d874a928372a5321886850587fa4 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Wed, 19 Jul 2023 17:51:31 -0700 Subject: [PATCH 6/9] fix static server --- cli/test/fixtures/static-server.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cli/test/fixtures/static-server.js b/cli/test/fixtures/static-server.js index e06319549aa9..e402c7c501aa 100644 --- a/cli/test/fixtures/static-server.js +++ b/cli/test/fixtures/static-server.js @@ -169,7 +169,10 @@ class Server { headers['X-TotalFetchedSize'] = Buffer.byteLength(data) + JSON.stringify(headers).length; } - response.writeHead(statusCode, headers); + response.statusCode = statusCode; + for (const [name, value] of Object.entries(headers)) { + response.setHeader(name, value); + } const encoding = charset === 'UTF-8' ? 'utf-8' : 'binary'; // Delay the response @@ -188,9 +191,8 @@ class Server {

Smoke test fixtures

${fixturePaths.map(p => `${escape(p)}`).join('
')} `; - response.writeHead(200, { - 'Content-Security-Policy': `default-src 'none';`, - }); + response.statusCode = 200; + response.setHeader('Content-Security-Policy', `default-src 'none';`); sendResponse(200, html); return; } @@ -227,16 +229,14 @@ class Server { function sendRedirect(url) { // Redirects can only contain ASCII characters. if (url.split('').some(char => char.charCodeAt(0) > 256)) { - response.writeHead(500); + response.statusCode = 500; response.write(`Invalid redirect URL: ${url}`); response.end(); return; } - const headers = { - Location: url, - }; - response.writeHead(302, headers); + response.statusCode = 302; + response.setHeader('Location', url); response.end(); } From 6eacbab250b74d731ec40e9949b45d67cdf7438d Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Thu, 20 Jul 2023 10:56:33 -0700 Subject: [PATCH 7/9] index cli --- cli/test/cli/index-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/test/cli/index-test.js b/cli/test/cli/index-test.js index e9e04c953851..0897129b3df8 100644 --- a/cli/test/cli/index-test.js +++ b/cli/test/cli/index-test.js @@ -76,7 +76,8 @@ describe('CLI Tests', function() { const ret = spawnSync('node', [indexPath, 'https://www.google.com', '--extra-headers', '{notjson}'], {encoding: 'utf8'}); - assert.ok(ret.stderr.includes('Unexpected token')); + // This message was changed in Node 20, check for old and new versions. + assert.ok(/(Unexpected token|Expected property name)/.test(ret.stderr)); assert.equal(ret.status, 1); }); }); From ea9456be9132f48cfd94137342852a763a503b38 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Thu, 27 Jul 2023 13:11:54 -0700 Subject: [PATCH 8/9] minor version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 533a8ee8a3cb..0253cd3c5985 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "smokehouse": "./cli/test/smokehouse/frontends/smokehouse-bin.js" }, "engines": { - "node": ">=18" + "node": ">=18.16" }, "scripts": { "prepack": "yarn build-report --standalone --flow --esm && yarn build-types", From d4ddf6b5a1cab9101fdc840362f5139647a3f7af Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Thu, 27 Jul 2023 13:14:50 -0700 Subject: [PATCH 9/9] gcp scripts --- core/scripts/gcp-collection/gcp-setup.sh | 2 +- core/scripts/lantern/collect/gcp-setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/scripts/gcp-collection/gcp-setup.sh b/core/scripts/gcp-collection/gcp-setup.sh index 69f7240f65d3..a6b81874d77a 100644 --- a/core/scripts/gcp-collection/gcp-setup.sh +++ b/core/scripts/gcp-collection/gcp-setup.sh @@ -17,7 +17,7 @@ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sud wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - # Node apt-key -curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - +curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - # Install dependencies sudo apt-get update diff --git a/core/scripts/lantern/collect/gcp-setup.sh b/core/scripts/lantern/collect/gcp-setup.sh index 66b78d4a9aca..563bd9afe31f 100644 --- a/core/scripts/lantern/collect/gcp-setup.sh +++ b/core/scripts/lantern/collect/gcp-setup.sh @@ -11,7 +11,7 @@ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sud wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - # Node apt-key -curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - +curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - # Install dependencies sudo apt-get update