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

v21.3.0 proposal #50954

Merged
merged 114 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
982b576
test: migrate message v8 tests from Python to JS
jahjahLemonade Oct 29, 2023
0bd694a
test_runner: add tests for various mock timer issues
mika-fischer Nov 12, 2023
7ebc8c2
test,stream: enable compression WPTs
panva Nov 8, 2023
146ad9c
stream: treat compression web stream format per its WebIDL definition
panva Nov 9, 2023
0d556d9
tools: update lint-md-dependencies to [email protected]
nodejs-github-bot Nov 12, 2023
75265e4
test: replace forEach with for...of
SpaceDux Nov 12, 2023
3731f83
deps: V8: cherry-pick 8f0b94671ddb
luyahan Nov 12, 2023
57587de
src: handle errors from uv_pipe_connect2()
deokjinkim Nov 12, 2023
8746073
src: avoid silent coercion to signed/unsigned int
tniessen Nov 12, 2023
673de30
node-api: factor out common code into macros
gabrielschulhof Nov 12, 2023
c494838
tools: change minimatch install strategy
marco-ippolito Nov 13, 2023
342a83e
test: change forEach to for...of in path extname
marquicodes Nov 13, 2023
4a1ce45
src: make process binding data weak
legendecas Nov 9, 2023
5c58341
src: create worker per isolate properties
legendecas Nov 9, 2023
91aa9dd
src: create fs_dir per isolate properties
legendecas Nov 9, 2023
aadff07
src: create per isolate proxy env template
legendecas Nov 9, 2023
bc3f7b5
module: remove useCustomLoadersIfPresent flag
legendecas Nov 9, 2023
c7a7493
module: bootstrap module loaders in shadow realm
legendecas Nov 9, 2023
0d3aa72
src: return error --env-file if file is not found
ardinugrxha Nov 14, 2023
377dede
test: test streambase has already has a consumer
MrJithil May 18, 2023
5d28f8d
deps: escape Python strings correctly
targos Nov 14, 2023
2e8e237
src: fix JSONParser leaking internal V8 scopes
kvakil Nov 14, 2023
5ef6729
tools: remove unused file
UlisesGascon Nov 8, 2023
713fdf1
doc: run license-builder
github-actions[bot] Nov 15, 2023
c81d2ac
benchmark: remove punycode from require-builtins fixture
joyeecheung Nov 15, 2023
db8ce5b
tools: recognize GN files in dep_updaters
zcbenz Nov 15, 2023
0e8275b
test: replace foreach with for
bluescreen Nov 15, 2023
52830b7
tools: add workflow to update release links
targos Nov 15, 2023
6b7403c
doc: fix `Buffer.allocUnsafe` documentation
mertcanaltin Nov 15, 2023
f7245d7
benchmark: add misc/startup-cli-version benchmark
joyeecheung Nov 15, 2023
dee8039
tls: fix order of setting cipher before setting cert and key
kumarrishav Oct 16, 2023
071e46a
deps: upgrade npm to 10.2.4
npm-cli-bot Nov 16, 2023
eaa4c14
util: improve performance of normalizeEncoding
kylo5aby Nov 16, 2023
465f75b
build: disable flag v8_scriptormodule_legacy_lifetime
legendecas Nov 17, 2023
27a4f58
permission: mark const functions as such
tniessen Nov 17, 2023
ead9879
doc: update print results(detail) in `PerformanceEntry`
Nov 17, 2023
6475cee
test: give more time to GC in test-shadow-realm-gc-*
joyeecheung Nov 14, 2023
4088b75
test: mark SEA tests as flaky on PowerPC
joyeecheung Nov 15, 2023
43da9ea
build: fix GN configuration for deps/base64
zcbenz Nov 17, 2023
28d78de
test: skip parallel/test-macos-app-sandbox if disk space < 120MB
joyeecheung Nov 17, 2023
4b26f14
test: improve test-bootstrap-modules.js
joyeecheung Nov 17, 2023
aebe2fc
perf_hooks: implement performance.now() with fast API calls
joyeecheung Nov 17, 2023
23f56d8
benchmark: rewrite import.meta benchmark
joyeecheung Nov 18, 2023
a0c01b2
deps: update simdutf to 4.0.4
nodejs-github-bot Nov 18, 2023
b4935dd
doc: fix fs.writeFileSync return value documentation
RyanZim Nov 18, 2023
f2e0fce
test: replace forEach() with for-loop
jabro86 Nov 18, 2023
36380eb
benchmark: increase the iteration number to an appropriate value
Nov 19, 2023
a275155
stream: add Symbol.toStringTag to Compression Streams
panva Nov 13, 2023
2e0abed
stream: yield expected Error class on zlib errors
panva Nov 13, 2023
f25637b
test: update WPT files for WebIDL tests
panva Nov 13, 2023
83ad272
src: remove erroneous default argument in RadixTree
tniessen Nov 19, 2023
0fb35b6
src: avoid copying strings in FSPermission::Apply
tniessen Nov 19, 2023
c8d4cd6
test: replace forEach in whatwg-encoding-custom-interop
HonzaMac Nov 19, 2023
eacf4ba
src: iterate on import attributes array correctly
targos Nov 19, 2023
c3eee59
inspector: use private fields instead of symbols
anonrig Nov 19, 2023
12605e8
build: add configuration flag to enable Maglev
kvakil Nov 12, 2023
0e3b714
test: enable idlharness tests for encoding
MattiasBuelens Nov 20, 2023
8468daf
doc: update Crypto API doc for x509.keyUsage
DMeechan Nov 20, 2023
00dab30
deps: V8: cherry-pick 475c8cdf9a95
kvakil Nov 12, 2023
faf6a04
src: add IsolateScopes before using isolates
kvakil Nov 12, 2023
221952a
test: use ppc and ppc64 to skip SEA tests on PowerPC
joyeecheung Nov 21, 2023
ee69c61
deps: update minimatch to 9.0.3
nodejs-github-bot Nov 21, 2023
daa933d
tools: update lint-md-dependencies to [email protected]
nodejs-github-bot Nov 21, 2023
f216377
tools: update eslint to 8.54.0
nodejs-github-bot Nov 21, 2023
0e4d25e
test: use requires instead of flaky in console WPT status
panva Nov 21, 2023
221f02d
deps: update undici to 5.27.2
nodejs-github-bot Nov 21, 2023
9197b0f
net: check pipe mode and path
theanarkh Nov 21, 2023
3b79983
test: replace forEach() with for ... of in test-tls-getprotocol.js
SociableSteve Nov 21, 2023
82f0882
test: replace forEach with for-of in test-url-relative
vitosorriso Nov 21, 2023
4522e22
stream: fix enumerability of ReadableStream.prototype.values
MattiasBuelens Nov 17, 2023
e5cce00
stream: fix enumerability of ReadableStream.from
MattiasBuelens Nov 20, 2023
628a12a
test: add note about readable streams with type owning
MattiasBuelens Nov 17, 2023
ce8fc56
test: add note about unresolved spec issue
MattiasBuelens Nov 18, 2023
3ff2bda
deps: update ada to 2.7.4
nodejs-github-bot Nov 21, 2023
79ef39b
src: add `--disable-warning` option
Nov 21, 2023
d2c0dfb
crypto: update root certificates to NSS 3.95
nodejs-github-bot Nov 21, 2023
6dfe102
dns: call handle.setServers() with a valid array
lpinca Nov 21, 2023
c31ad5c
deps: update icu to 74.1
nodejs-github-bot Nov 1, 2023
5849f09
build: add GN configurations for simdjson
zcbenz Nov 21, 2023
a37d9ee
doc: fix typos in --allow-fs-*
tniessen Nov 22, 2023
e116fcd
doc: add CanadaHonk to triagers
CanadaHonk Nov 21, 2023
adcab85
src: fix compatility with upcoming V8 12.1 APIs
zcbenz Nov 22, 2023
a12d9e0
tools: use macOS keychain to notarize the releases
UlisesGascon Nov 13, 2023
98fb1fa
doc: create deprecation code for isWebAssemblyCompiledModule
marco-ippolito Nov 22, 2023
3fdecc4
permission: do not create symlinks if target is relative
tniessen Nov 22, 2023
08c3b0a
doc: get rid of unnecessary `eslint-skip` comments
aduh95 Nov 22, 2023
9dc4cde
fs: improve error perf of sync `lstat`+`fstat`
CanadaHonk Nov 23, 2023
bc31375
doc: shard not supported with watch mode
pulkit-30 Nov 23, 2023
9d76de1
test: replace foreach with for in test-https-simple.js
Nov 23, 2023
5de3053
tools: add macOS notarization verification step
UlisesGascon Nov 21, 2023
492e3e3
fs: replace deprecated `path._makeLong` in copyFile
CanadaHonk Nov 23, 2023
e02f304
deps: V8: cherry-pick 0f9ebbc672c7
legendecas Nov 24, 2023
7f44164
test: replace forEach to for at test-webcrypto-sign-verify-ecdsa.js
StiffWriter00 Nov 24, 2023
b1b6c44
test: replace forEach with for of
RBrNx Nov 24, 2023
7de900a
test: fix dns test case failures after c-ares update to 1.21.0+
bradh352 Nov 15, 2023
5811a59
meta: move cjihrig to TSC regular member
cjihrig Nov 24, 2023
fd9195d
src: fix coverity warning
mhdawson Nov 24, 2023
45b2bb0
fs: fix to not return for void function
Nov 24, 2023
8d3a1d8
deps: update zlib to 1.2.13.1-motley-5daffc7
nodejs-github-bot Nov 24, 2023
6485687
doc: update email to reflect affiliation
anonrig Nov 24, 2023
a5d959b
v8,tools: expose necessary V8 defines
zcbenz Nov 25, 2023
8c4976b
doc: add a section regarding `instanceof` in `primordials.md`
aduh95 Nov 25, 2023
65a811a
meta: clarify recommendation for bug reproductions
aduh95 Nov 25, 2023
feb8ff9
src: assert return value of BN_bn2binpad
tniessen Nov 25, 2023
e4e0add
fs: fix glob returning duplicates
MoLow Nov 26, 2023
4a20912
benchmark: update iterations in benchmark/util/splice-one.js
Septa2112 Nov 26, 2023
1a0069b
meta: clarify nomination process according to Node.js charter
mcollina Nov 26, 2023
483200f
fs: improve error performance for `rmdirSync`
CanadaHonk Nov 26, 2023
e59268a
fs: add c++ fast path for writeFileSync utf8
CanadaHonk Nov 27, 2023
2f13db4
doc: make theme consistent across api and other docs
demakoff Nov 27, 2023
087cffc
test: fix message v8 not normalising alphanumeric paths
MrJithil Nov 14, 2023
bd58870
esm: do not call `getSource` when format is `commonjs`
fasttime Nov 29, 2023
50f336c
esm: fallback to `getSource` when `load` returns nullish `source`
aduh95 Nov 29, 2023
1f0ba08
2023-11-30, Version 21.3.0 (Current)
RafaelGSS Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion .github/ISSUE_TEMPLATE/1-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ body:
- type: textarea
attributes:
label: What steps will reproduce the bug?
description: Enter details about your bug, preferably a simple code snippet that can be run using `node` directly without installing third-party dependencies.
description: >
Enter details about your bug, preferably a simple code snippet that can
be run using `node` directly without installing third-party dependencies
or downloading code from the internet (i.e. no ZIP archive, no GitHub
repository, etc.).
- type: textarea
attributes:
label: How often does it reproduce? Is there a required condition?
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/update-release-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Update release links

on:
release:
types: [published]

permissions:
contents: read

jobs:
update-release-links:
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
steps:
- name: Trigger update-links workflow on nodejs/release-cloudflare-worker
run: |
gh workflow run update-links.yml --repo nodejs/release-cloudflare-worker
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ xiaoyu <[email protected]>
Xu Meng <[email protected]> <[email protected]>
Xuguang Mei <[email protected]> <[email protected]>
Yael Hermon <[email protected]> <[email protected]>
Yagiz Nizipli <[email protected]> <[email protected]>
Yang Guo <[email protected]>
Yash Ladha <[email protected]> <[email protected]>
Yash Ladha <[email protected]> <[email protected]>
Expand Down
6 changes: 6 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ make docopen
This will open a file URL to a one-page version of all the browsable HTML
documents using the default browser.

```bash
make docclean
```

This will clean previously built doc.

To test if Node.js was built correctly:

```bash
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ release.
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V21.md#21.2.0">21.2.0</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V21.md#21.3.0">21.3.0</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V21.md#21.2.0">21.2.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V21.md#21.1.0">21.1.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V21.md#21.0.0">21.0.0</a><br/>
</td>
Expand Down
5 changes: 3 additions & 2 deletions GOVERNANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ Provide a summary of the nominee's contributions. For example:
Mention @nodejs/collaborators in the issue to notify other collaborators about
the nomination.

The nomination passes if no collaborators oppose it after one week. Otherwise,
the nomination fails.
The nomination passes if no collaborators oppose it after one week. In the case
of an objection, the TSC is responsible for working with the individuals
involved and finding a resolution.

There are steps a nominator can take in advance to make a nomination as
frictionless as possible. To request feedback from other collaborators in
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2153,9 +2153,9 @@ The externally maintained libraries used by Node.js are:
- base64, located at deps/base64/base64/, is licensed as follows:
"""
Copyright (c) 2005-2007, Nick Galbreath
Copyright (c) 2013-2019, Alfred Klomp
Copyright (c) 2015-2017, Wojciech Mula
Copyright (c) 2015-2018, Wojciech Muła
Copyright (c) 2016-2017, Matthieu Darbois
Copyright (c) 2013-2022, Alfred Klomp
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ For information about the governance of the Node.js project, see
* [aduh95](https://github.com/aduh95) -
**Antoine du Hamel** <<[email protected]>> (he/him)
* [anonrig](https://github.com/anonrig) -
**Yagiz Nizipli** <<yagiz@nizipli.com>> (he/him)
**Yagiz Nizipli** <<yagiz.nizipli@sentry.io>> (he/him)
* [apapirovski](https://github.com/apapirovski) -
**Anatoli Papirovski** <<[email protected]>> (he/him)
* [benjamingr](https://github.com/benjamingr) -
**Benjamin Gruenbaum** <<[email protected]>>
* [BridgeAR](https://github.com/BridgeAR) -
**Ruben Bridgewater** <<[email protected]>> (he/him)
* [cjihrig](https://github.com/cjihrig) -
**Colin Ihrig** <<[email protected]>> (he/him)
* [GeoffreyBooth](https://github.com/geoffreybooth) -
**Geoffrey Booth** <<[email protected]>> (he/him)
* [gireeshpunathil](https://github.com/gireeshpunathil) -
Expand Down Expand Up @@ -213,6 +211,8 @@ For information about the governance of the Node.js project, see
**Ben Noordhuis** <<[email protected]>>
* [ChALkeR](https://github.com/ChALkeR) -
**Сковорода Никита Андреевич** <<[email protected]>> (he/him)
* [cjihrig](https://github.com/cjihrig) -
**Colin Ihrig** <<[email protected]>> (he/him)
* [codebytere](https://github.com/codebytere) -
**Shelley Vohr** <<[email protected]>> (she/her)
* [danbev](https://github.com/danbev) -
Expand Down Expand Up @@ -288,7 +288,7 @@ For information about the governance of the Node.js project, see
* [aduh95](https://github.com/aduh95) -
**Antoine du Hamel** <<[email protected]>> (he/him)
* [anonrig](https://github.com/anonrig) -
**Yagiz Nizipli** <<yagiz@nizipli.com>> (he/him)
**Yagiz Nizipli** <<yagiz.nizipli@sentry.io>> (he/him)
* [antsmartian](https://github.com/antsmartian) -
**Anto Aravinth** <<[email protected]>> (he/him)
* [apapirovski](https://github.com/apapirovski) -
Expand Down Expand Up @@ -715,6 +715,8 @@ maintaining the Node.js project.
**Qingyu Deng** <<[email protected]>>
* [bmuenzenmeyer](https://github.com/bmuenzenmeyer) -
**Brian Muenzenmeyer** <<[email protected]>> (he/him)
* [CanadaHonk](https://github.com/CanadaHonk) -
**Oliver Medhurst** <<[email protected]>> (they/them)
* [daeyeon](https://github.com/daeyeon) -
**Daeyeon Jeong** <<[email protected]>> (he/him)
* [F3n67u](https://github.com/F3n67u) -
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/webcrypto-digest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
sync: ['createHash', 'subtle'],
data: [10, 20, 50, 100],
method: ['SHA-1', 'SHA-256', 'SHA-384', 'SHA-512'],
n: [1e3],
n: [1e5],
});

const kMethods = {
Expand Down
32 changes: 32 additions & 0 deletions benchmark/esm/import-meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

const path = require('path');
const { pathToFileURL, fileURLToPath } = require('url');
const common = require('../common');
const assert = require('assert');
const bench = common.createBenchmark(main, {
n: [1000],
});

const file = pathToFileURL(
path.resolve(__filename, '../../fixtures/esm-dir-file.mjs'),
);
async function load(array, n) {
for (let i = 0; i < n; i++) {
array[i] = await import(`${file}?i=${i}`);
}
return array;
}

function main({ n }) {
const array = [];
for (let i = 0; i < n; ++i) {
array.push({ dirname: '', filename: '', i: 0 });
}

bench.start();
load(array, n).then((arr) => {
bench.end(n);
assert.strictEqual(arr[n - 1].filename, fileURLToPath(file));
});
}
5 changes: 2 additions & 3 deletions benchmark/fixtures/esm-dir-file.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import assert from 'assert';
assert.ok(import.meta.dirname);
assert.ok(import.meta.filename);
export const dirname = import.meta.dirname;
export const filename = import.meta.filename;
5 changes: 0 additions & 5 deletions benchmark/fixtures/load-esm-dir-file.js

This file was deleted.

1 change: 0 additions & 1 deletion benchmark/fixtures/require-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const list = [
'path',
'perf_hooks',
'process',
'punycode',
'querystring',
'readline',
'repl',
Expand Down
42 changes: 42 additions & 0 deletions benchmark/fs/bench-rmdirSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const common = require('../common');
const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

const bench = common.createBenchmark(main, {
type: ['existing', 'non-existing'],
n: [1e4],
});

function main({ n, type }) {
switch (type) {
case 'existing': {
for (let i = 0; i < n; i++) {
fs.mkdirSync(tmpdir.resolve(`rmdirsync-bench-dir-${i}`));
}

bench.start();
for (let i = 0; i < n; i++) {
fs.rmdirSync(tmpdir.resolve(`rmdirsync-bench-dir-${i}`));
}
bench.end(n);
break;
}
case 'non-existing': {
bench.start();
for (let i = 0; i < n; i++) {
try {
fs.rmdirSync(tmpdir.resolve(`.non-existent-folder-${i}`));
} catch {
// do nothing
}
}
bench.end(n);
break;
}
default:
new Error('Invalid type');
}
}
22 changes: 15 additions & 7 deletions benchmark/fs/bench-statSync-failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ const fs = require('fs');
const path = require('path');

const bench = common.createBenchmark(main, {
n: [1e6],
statSyncType: ['throw', 'noThrow'],
n: [1e4],
statSyncType: ['fstatSync', 'lstatSync', 'statSync'],
throwType: [ 'throw', 'noThrow' ],
}, {
// fstatSync does not support throwIfNoEntry
combinationFilter: ({ statSyncType, throwType }) => !(statSyncType === 'fstatSync' && throwType === 'noThrow'),
});


function main({ n, statSyncType }) {
const arg = path.join(__dirname, 'non.existent');
function main({ n, statSyncType, throwType }) {
const arg = (statSyncType === 'fstatSync' ?
(1 << 30) :
path.join(__dirname, 'non.existent'));

const fn = fs[statSyncType];

bench.start();
for (let i = 0; i < n; i++) {
if (statSyncType === 'noThrow') {
fs.statSync(arg, { throwIfNoEntry: false });
if (throwType === 'noThrow') {
fn(arg, { throwIfNoEntry: false });
} else {
try {
fs.statSync(arg);
fn(arg);
} catch {
// Continue regardless of error.
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/bench-statSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common');
const fs = require('fs');

const bench = common.createBenchmark(main, {
n: [1e6],
n: [1e4],
statSyncType: ['fstatSync', 'lstatSync', 'statSync'],
});

Expand Down
43 changes: 43 additions & 0 deletions benchmark/fs/bench-writeFileSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const common = require('../common.js');
const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

// Some variants are commented out as they do not show a change and just slow
const bench = common.createBenchmark(main, {
encoding: ['utf8'],
useFd: ['true', 'false'],
length: [1024, 102400, 1024 * 1024],

// useBuffer: ['true', 'false'],
useBuffer: ['false'],

// func: ['appendFile', 'writeFile'],
func: ['writeFile'],

n: [1e3],
});

function main({ n, func, encoding, length, useFd, useBuffer }) {
tmpdir.refresh();
const enc = encoding === 'undefined' ? undefined : encoding;
const path = tmpdir.resolve(`.writefilesync-file-${Date.now()}`);

useFd = useFd === 'true';
const file = useFd ? fs.openSync(path, 'w') : path;

let data = 'a'.repeat(length);
if (useBuffer === 'true') data = Buffer.from(data, encoding);

const fn = fs[func + 'Sync'];

bench.start();
for (let i = 0; i < n; ++i) {
fn(file, data, enc);
}
bench.end(n);

if (useFd) fs.closeSync(file);
}
51 changes: 51 additions & 0 deletions benchmark/misc/startup-cli-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
const common = require('../common.js');
const { spawnSync } = require('child_process');
const path = require('path');

// This benchmarks the startup of various CLI tools that are already
// checked into the source code. We use --version because the output
// tends to be minimal and fewer operations are done to generate
// these so that the startup cost is still dominated by a more
// indispensible part of the CLI.
const bench = common.createBenchmark(main, {
cli: [
'tools/node_modules/eslint/bin/eslint.js',
'deps/npm/bin/npm-cli.js',
'deps/corepack/dist/corepack.js',
],
count: [30],
});

function spawnProcess(cli, bench, state) {
const cmd = process.execPath || process.argv[0];
while (state.finished < state.count) {
const child = spawnSync(cmd, [cli, '--version'], {
env: { npm_config_loglevel: 'silent', ...process.env },
});
// Log some information for debugging if it fails, which it shouldn't.
if (child.status !== 0) {
console.log('---- STDOUT ----');
console.log(child.stdout.toString());
console.log('---- STDERR ----');
console.log(child.stderr.toString());
throw new Error(`Child process stopped with exit code ${child.status}`);
}
state.finished++;
if (state.finished === 0) {
// Finished warmup.
bench.start();
}

if (state.finished === state.count) {
bench.end(state.count);
}
}
}

function main({ count, cli }) {
cli = path.resolve(__dirname, '../../', cli);
const warmup = 3;
const state = { count, finished: -warmup };
spawnProcess(cli, bench, state);
}
1 change: 0 additions & 1 deletion benchmark/misc/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const bench = common.createBenchmark(main, {
script: [
'benchmark/fixtures/require-builtins',
'test/fixtures/semicolon',
'benchmark/fixtures/load-esm-dir-file',
],
mode: ['process', 'worker'],
count: [30],
Expand Down
Loading