Skip to content

Commit 9802e91

Browse files
committed
fix: support node20
1 parent 320314e commit 9802e91

File tree

12 files changed

+69
-25
lines changed

12 files changed

+69
-25
lines changed

.github/workflows/run-tests.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- windows-latest
2121
- macos-latest
2222
node:
23+
- 20
2324
- 22
2425
- 24
2526
steps:
@@ -32,16 +33,30 @@ jobs:
3233
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
3334
with:
3435
cache: npm
35-
node-version: ${{ matrix.node }}
36+
node-version: 22
3637

3738
- name: Install dependencies
3839
run: npm ci
3940

41+
- name: Build
42+
run: npm run build
43+
44+
- name: Set up Node.js
45+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
46+
with:
47+
cache: npm
48+
node-version: ${{ matrix.node }}
49+
4050
- name: Disable AppArmor
4151
if: ${{ matrix.os == 'ubuntu-latest' }}
4252
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
4353

54+
- name: Run tests (node20)
55+
if: ${{ matrix.node == '20' }}
56+
run: npm run test:node20
57+
4458
- name: Run tests
59+
if: ${{ matrix.node != '20' }}
4560
run: npm run test
4661

4762
# Gating job for branch protection.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MCP clients.
2626

2727
## Requirements
2828

29-
- [Node.js 22](https://nodejs.org/) or newer.
29+
- [Node.js 20](https://nodejs.org/) or newer.
3030
- [Chrome](https://www.google.com/chrome/) current stable version or newer.
3131
- [npm](https://www.npmjs.com/).
3232

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"docs:generate": "node --experimental-strip-types scripts/generate-docs.ts",
1717
"start": "npm run build && node build/src/index.js",
1818
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
19+
"test:node20": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test 'build/tests'",
1920
"test": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test 'build/tests/**/*.test.js'",
2021
"test:only": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
2122
"test:only:no-build": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
@@ -50,7 +51,7 @@
5051
"@types/yargs": "^17.0.33",
5152
"@typescript-eslint/eslint-plugin": "^8.43.0",
5253
"@typescript-eslint/parser": "^8.43.0",
53-
"chrome-devtools-frontend": "1.0.1515796",
54+
"chrome-devtools-frontend": "1.0.1516909",
5455
"eslint": "^9.35.0",
5556
"globals": "^16.4.0",
5657
"prettier": "^3.6.2",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* SPDX-License-Identifier: Apache-2.0
66
*/
77

8+
import './polyfill.js';
9+
810
import {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js';
911
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
1012
import {

src/polyfill.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// For Node 20.
8+
if (!Promise.withResolvers) {
9+
Promise.withResolvers = function <T>() {
10+
let resolve, reject;
11+
const promise = new Promise<T>((_resolve, _reject) => {
12+
resolve = _resolve;
13+
reject = _reject;
14+
});
15+
return {promise, resolve, reject} as unknown as ReturnType<
16+
typeof Promise.withResolvers<T>
17+
>;
18+
};
19+
}

tests/setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
*/
66
import {it} from 'node:test';
77

8+
if (!it.snapshot) {
9+
it.snapshot = {
10+
setResolveSnapshotPath: () => {},
11+
setDefaultSnapshotSerializers: () => {},
12+
};
13+
}
14+
815
// This is run by Node when we execute the tests via the --require flag.
916
it.snapshot.setResolveSnapshotPath(testPath => {
1017
// By default the snapshots go into the build directory, but we want them

tests/tools/performance.test.js.snapshot

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ exports[`performance > performance_analyze_insight > returns the information on
55
This insight is used to analyze the time spent that contributed to the final LCP time and identify which of the 4 phases (or 2 if there was no LCP resource) are contributing most to the delay in rendering the LCP element.
66

77
## Detailed analysis:
8-
The Largest Contentful Paint (LCP) time for this navigation was 129.2 ms.
8+
The Largest Contentful Paint (LCP) time for this navigation was 129 ms.
99
The LCP element is an image fetched from \`https://web-dev.imgix.net/image/kheDArv5csY6rvQUJDbWRscckLr1/4i7JstVZvgTFk9dxCe4a.svg\`.
1010
## LCP resource network request: https://web-dev.imgix.net/image/kheDArv5csY6rvQUJDbWRscckLr1/4i7JstVZvgTFk9dxCe4a.svg
1111
Timings:
12-
- Queued at: 41.1 ms
13-
- Request sent at: 46.6 ms
14-
- Download complete at: 55.8 ms
15-
- Main thread processing completed at: 58.2 ms
12+
- Queued at: 41 ms
13+
- Request sent at: 47 ms
14+
- Download complete at: 56 ms
15+
- Main thread processing completed at: 58 ms
1616
Durations:
1717
- Download time: 0.3 ms
18-
- Main thread processing time: 2.3 ms
19-
- Total duration: 17.1 ms
18+
- Main thread processing time: 2 ms
19+
- Total duration: 17 ms
2020
Redirects: no redirects
2121
Status code: 200
2222
MIME Type: image/svg+xml
@@ -29,10 +29,10 @@ Initiators (root request to the request that directly loaded this one): none
2929

3030
We can break this time down into the 4 phases that combine to make the LCP time:
3131

32-
- Time to first byte: 7.9 ms (6.1% of total LCP time)
33-
- Resource load delay: 33.2 ms (25.7% of total LCP time)
34-
- Resource load duration: 14.7 ms (11.4% of total LCP time)
35-
- Element render delay: 73.4 ms (56.8% of total LCP time)
32+
- Time to first byte: 8 ms (6.1% of total LCP time)
33+
- Resource load delay: 33 ms (25.7% of total LCP time)
34+
- Resource load duration: 15 ms (11.4% of total LCP time)
35+
- Element render delay: 73 ms (56.8% of total LCP time)
3636

3737
## Estimated savings: none
3838

tests/tools/performance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('performance', () => {
161161
context,
162162
);
163163

164-
t.assert.snapshot(response.responseLines.join('\n'));
164+
t.assert.snapshot?.(response.responseLines.join('\n'));
165165
});
166166
});
167167

tests/trace-processing/parse.test.js.snapshot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Network throttling: none
66
Metrics (lab / observed):
77
- LCP: 129 ms, event: (eventKey: r-6063, ts: 122411126100)
88
- LCP breakdown:
9-
- TTFB: 7.9 ms, bounds: {min: 122410996889, max: 122411004828}
10-
- Load delay: 33.2 ms, bounds: {min: 122411004828, max: 122411037986}
11-
- Load duration: 14.7 ms, bounds: {min: 122411037986, max: 122411052690}
12-
- Render delay: 73.4 ms, bounds: {min: 122411052690, max: 122411126100}
9+
- TTFB: 8 ms, bounds: {min: 122410996889, max: 122411004828}
10+
- Load delay: 33 ms, bounds: {min: 122411004828, max: 122411037986}
11+
- Load duration: 15 ms, bounds: {min: 122411037986, max: 122411052690}
12+
- Render delay: 73 ms, bounds: {min: 122411052690, max: 122411126100}
1313
- CLS: 0.00
1414
Metrics (field / real users): n/a – no data for this page in CrUX
1515
Available insights:

0 commit comments

Comments
 (0)