Skip to content

Commit 4096767

Browse files
deps: update undici to 8.12.2
PR-URL: #66721 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent c0c8ce8 commit 4096767

109 files changed

Lines changed: 15151 additions & 4048 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎deps/undici/src/CONTRIBUTING.md‎

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* [Guides](#guides)
44
* [Update `llhttp`](#update-llhttp)
5+
* [Update `milo`](#update-milo)
56
* [Lint](#lint)
67
* [Test](#test)
78
* [Coverage](#coverage)
@@ -59,7 +60,7 @@ npm i
5960
> This requires [docker](https://www.docker.com/) installed on your machine.
6061
6162
```bash
62-
npm run build:wasm
63+
npm run build-wasm
6364
```
6465

6566
#### Copy the sources to `undici`
@@ -83,13 +84,94 @@ cp src/native/api.h build/llhttp.h <your-path-to-undici>/deps/llhttp/include/
8384
```bash
8485
cd <your-path-to-undici>
8586

86-
npm run build:wasm
87+
npm run build:llhttp
8788
```
8889

8990
#### Commit the contents of lib/llhttp
9091

9192
Create a commit which includes all of the updated files in lib/llhttp.
9293

94+
<a id="update-milo"></a>
95+
### Update `milo`
96+
97+
Milo is built from the upstream sources vendored in `deps/milo`, using its own
98+
Dockerfile rather than a prebuilt npm package. Updating it is manual, like llhttp.
99+
The standalone release CommonJS modules and their license are saved in `lib/milo`.
100+
101+
The current vendored release is 0.8.5 at commit
102+
`2ec4642184f20cd1803e30650becc54bbd575c6c`.
103+
104+
#### Clone milo and checkout a release
105+
106+
```sh
107+
git clone https://github.com/ShogunPanda/milo.git
108+
cd milo
109+
git checkout v0.8.5
110+
```
111+
112+
#### Copy the sources into Undici
113+
114+
Replace the previous contents of `deps/milo` with the following files and
115+
directories from the selected release, preserving their layout:
116+
117+
```sh
118+
cp Dockerfile Makefile.toml rust-toolchain.toml LICENSE.md README.md CODE_OF_CONDUCT.md <your-path-to-undici>/deps/milo/
119+
cp -R macros scripts <your-path-to-undici>/deps/milo/
120+
mkdir -p <your-path-to-undici>/deps/milo/parser
121+
cp parser/*.toml parser/*.lock parser/*.md <your-path-to-undici>/deps/milo/parser/
122+
cp -R parser/src <your-path-to-undici>/deps/milo/parser/
123+
```
124+
125+
Keep the Cargo manifests and all three lockfiles (`macros/Cargo.lock`,
126+
`parser/Cargo.lock` and `scripts/Cargo.lock`), Rust binding generators and JavaScript
127+
template. Preserve Undici's build adjustments: the Docker image digest, pinned
128+
cargo-make version, Binaryen checksums and `--locked` Cargo builds. Update the
129+
checksums for both Linux architectures whenever Binaryen is updated.
130+
Do not copy `parser/tests`, `parser/examples`, `.git`, upstream workflows,
131+
`target`, `dist`, or prebuilt npm packages. Use a clean checkout so no local build
132+
outputs are included. When selecting a newer release, update the version and
133+
full commit recorded above.
134+
135+
#### Build and copy the release artifacts
136+
137+
Docker is the only build tool required on the host. The upstream image installs
138+
Rust, cargo-make and Binaryen, then runs `makers wasm` in an internal copy of the
139+
read-only source checkout. See [milo's Docker build instructions](https://github.com/ShogunPanda/milo#building-webassembly-with-docker).
140+
141+
From Undici, build the vendored sources:
142+
143+
```sh
144+
cd <your-path-to-undici>
145+
npm run build:milo
146+
```
147+
148+
`build/milo.js` follows those instructions, mounts `deps/milo` read-only, and
149+
copies only these release artifacts:
150+
151+
```text
152+
release/package-cjs/src/simd/index.js -> lib/milo/simd.js
153+
release/package-cjs/src/no-simd/index.js -> lib/milo/no-simd.js
154+
release/package-cjs/LICENSE.md -> lib/milo/LICENSE.md
155+
```
156+
157+
Each JavaScript module already embeds its WASM binary in base64. Separate `.wasm`
158+
files, unbundled modules, debug packages and package metadata are not copied.
159+
Temporary Docker outputs are removed when the script finishes. The script does
160+
not download or update milo's sources; Docker still downloads the image and build
161+
dependencies as needed.
162+
163+
The shared-builtin CI job removes the bundled Milo modules and rebuilds them
164+
before compiling Node.js, so that it cannot silently reuse prebuilt artifacts.
165+
The npm package contains only the license and the two bundled JavaScript modules;
166+
`lib/milo/binary`, `lib/milo/src` and separate WASM files are excluded.
167+
168+
#### Submit the update
169+
170+
Include the updated sources in `deps/milo`, generated files in `lib/milo` and
171+
the documentation update in a manually prepared PR. This step prepares milo's
172+
build inputs; it does not modify
173+
the runtime parser, llhttp's build script or any workflows.
174+
93175
<a id="update-wpts"></a>
94176
### Update `WPTs`
95177

@@ -176,9 +258,9 @@ Use the "Create release PR" github action to generate a release PR.
176258
If you are packaging `undici` for a distro, this might help if you would like to use
177259
an unbundled version instead of bundling one in `libnode.so`.
178260

179-
To enable this, pass `EXTERNAL_PATH=/path/to/global/node_modules/undici` to `build/wasm.js`.
261+
To enable this, pass `EXTERNAL_PATH=/path/to/global/node_modules/undici` to `build/llhttp.js`.
180262
Pass this path with `loader.js` appended to `--shared-builtin-undici/undici-path` in Node.js's `configure.py`.
181-
If building on a non-Alpine Linux distribution, you may need to also set the `WASM_CC`, `WASM_CFLAGS`, `WASM_LDFLAGS` and `WASM_LDLIBS` environment variables before running `build/wasm.js`.
263+
If building on a non-Alpine Linux distribution, you may need to also set the `WASM_CC`, `WASM_CFLAGS`, `WASM_LDFLAGS` and `WASM_LDLIBS` environment variables before running `build/llhttp.js`.
182264
Similarly, you can set the `WASM_OPT` environment variable to utilize your own `wasm-opt` optimizer.
183265

184266
<a id="benchmarks"></a>

‎deps/undici/src/README.md‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ Using [benchmark-http2.js](https://github.com/nodejs/undici/blob/main/benchmarks
8686

8787
Node.js includes a built-in `fetch()` implementation powered by undici starting from Node.js v18. However, there are important differences between using the built-in fetch and installing undici as a separate module.
8888

89+
### WebAssembly requirement
90+
91+
Undici's HTTP/1 parser requires WebAssembly. There is no alternative parser when
92+
WebAssembly is unavailable, for example in Node.js configurations where
93+
`--jitless` disables it. The existence of `fetch` does not imply that it can make
94+
HTTP/1 requests in that environment.
95+
96+
When the HTTP/1 parser is needed without WebAssembly, Client and dispatcher
97+
requests fail with an `Error` whose code is `ERR_WEBASSEMBLY_NOT_SUPPORTED`.
98+
`fetch` rejects with a `TypeError` carrying that error in `error.cause`. Importing
99+
Undici, accessing `fetch`, and using `Headers`, `FormData`, `Request`, or `Response`
100+
do not themselves require the HTTP/1 parser.
101+
102+
The error is defined locally in Undici and does not depend on Node.js providing
103+
that error code. For built-in fetch, this behavior depends on the bundled Undici
104+
version. Node.js receives upstream fixes through its normal vendored Undici
105+
update, rather than changes to the generated bundle alone.
106+
89107
### Built-in Fetch (Node.js v18+)
90108

91109
Node.js's built-in fetch is powered by a bundled version of undici:
@@ -773,14 +791,18 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es
773791

774792
## Collaborators
775793

776-
* [__Daniele Belardi__](https://github.com/dnlup), <https://www.npmjs.com/~dnlup>
777-
* [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
794+
* [__Aras Abbasi__](https://github.com/Uzlopak)
795+
* [__Carlos Fuentes__](https://github.com/metcoder95), <https://www.npmjs.com/~metcoder95>
796+
* [__Ethan Arrowood__](https://github.com/Ethan-Arrowood), <https://www.npmjs.com/~ethan_arrowood>
778797
* [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
779798
* [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
799+
* [__Mert Can Altin__](https://github.com/mertcanaltin), <https://www.npmjs.com/~mertcanaltin>
780800
* [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
781-
* [__Szymon Marczak__](https://github.com/szmarczak), <https://www.npmjs.com/~szmarczak>
801+
* [__Trivikram Kamat__](https://github.com/trivikr), <https://www.npmjs.com/~trivikr>
802+
* [__tsctx__](https://github.com/tsctx)
782803

783804
## Past Collaborators
805+
* [__Szymon Marczak__](https://github.com/szmarczak), <https://www.npmjs.com/~szmarczak>
784806
* [__Tomas Della Vedova__](https://github.com/delvedor), <https://www.npmjs.com/~delvedor>
785807

786808
### Releasers
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ if (process.argv[2] === '--docker') {
6262
cmd += ` --mount type=bind,source=${ROOT}/lib/llhttp,target=/home/node/build/lib/llhttp \
6363
--mount type=bind,source=${ROOT}/build,target=/home/node/build/build \
6464
--mount type=bind,source=${ROOT}/deps,target=/home/node/build/deps \
65-
-t ${WASM_BUILDER_CONTAINER} node build/wasm.js`
65+
-t ${WASM_BUILDER_CONTAINER} node build/llhttp.js`
6666
console.log(`> ${cmd}\n\n`)
6767
execSync(cmd, { stdio: 'inherit' })
6868
process.exit(0) // eslint-disable-line n/no-process-exit

‎deps/undici/src/build/milo.js‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict'
2+
3+
const { execFileSync } = require('node:child_process')
4+
const { chmod, mkdtemp, readFile, cp, rm, mkdir } = require('node:fs/promises')
5+
const { resolve } = require('node:path')
6+
7+
const artifacts = {
8+
'release/package-cjs/src/no-simd/index.js': 'no-simd.js',
9+
'release/package-cjs/src/simd/index.js': 'simd.js',
10+
'release/package-cjs/LICENSE.md': 'LICENSE.md'
11+
}
12+
13+
function docker (...args) {
14+
return execFileSync('docker', args, { stdio: 'inherit' })
15+
}
16+
17+
async function buildMilo () {
18+
// Setup some folders
19+
const source = resolve(__dirname, '../deps/milo')
20+
const destination = resolve(__dirname, '../lib/milo')
21+
const temporary = await mkdtemp(resolve(__dirname, '../deps/.build-'))
22+
const imageFile = resolve(temporary, 'id')
23+
24+
try {
25+
await chmod(temporary, 0o777)
26+
docker('build', '--iidfile', imageFile, source)
27+
28+
const image = (await readFile(imageFile, 'utf8')).trim()
29+
if (!/^sha256:[a-f0-9]{64}$/.test(image)) {
30+
throw new Error('Docker did not return a valid milo build image ID')
31+
}
32+
33+
// Follow upstream's README: sources are read-only; only results are mounted writable.
34+
const sourceMount = `type=bind,source=${source},target=/src,readonly`
35+
const outputMount = `type=bind,source=${temporary},target=/output`
36+
docker('run', '--rm', '--mount', sourceMount, '--mount', outputMount, image)
37+
38+
// Clean the destination directory and recreate it before copying artifacts.
39+
await rm(destination, { recursive: true, force: true })
40+
await mkdir(destination, { recursive: true })
41+
42+
// Copy artifacts from the temporary build output to the destination directory.
43+
for (const [from, to] of Object.entries(artifacts)) {
44+
await cp(resolve(temporary, from), resolve(destination, to))
45+
}
46+
47+
console.log(`Milo release artifacts saved in ${destination}`)
48+
} finally {
49+
await rm(temporary, { recursive: true, force: true })
50+
}
51+
}
52+
53+
buildMilo()
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ghcr.io/nodejs/wasm-builder@sha256:542fdbef9fa6eb003cc1eb89a9f3e6b967359471fdb29db4910c54474e70911d
2+
3+
USER root
4+
5+
ARG BINARYEN_VERSION=123
6+
ARG RUST_TOOLCHAIN=nightly-2026-07-29
7+
ARG CARGO_MAKE_VERSION=0.37.24
8+
9+
RUN set -eux; \
10+
case "$(uname -m)" in \
11+
x86_64) binaryen_arch=x86_64; binaryen_sha256=e959f2170af4c20c552e9de3a0253704d6a9d2766e8fdb88e4d6ac4bae9388fe ;; \
12+
aarch64) binaryen_arch=aarch64; binaryen_sha256=4b6bd61ba6cd3b18c993b4657d93426c782f9b91b74be0d38018cd8be1319376 ;; \
13+
*) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;; \
14+
esac; \
15+
wget -q "https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-${binaryen_arch}-linux.tar.gz" -O /tmp/binaryen.tar.gz; \
16+
echo "${binaryen_sha256} /tmp/binaryen.tar.gz" | sha256sum -c -; \
17+
tar -xzf /tmp/binaryen.tar.gz -C /tmp; \
18+
install -m 0755 "/tmp/binaryen-version_${BINARYEN_VERSION}/bin/wasm-opt" /usr/local/bin/wasm-opt; \
19+
rm -rf /tmp/binaryen.tar.gz "/tmp/binaryen-version_${BINARYEN_VERSION}"
20+
21+
USER node
22+
23+
RUN set -eux; \
24+
rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal; \
25+
rustup target add wasm32-unknown-unknown --toolchain "${RUST_TOOLCHAIN}"; \
26+
rustup component add rust-src --toolchain "${RUST_TOOLCHAIN}"; \
27+
cargo +"${RUST_TOOLCHAIN}" install cargo-make --version "${CARGO_MAKE_VERSION}" --locked
28+
29+
ENV PATH="/home/node/.cargo/bin:${PATH}"
30+
ENV RUSTUP_TOOLCHAIN=${RUST_TOOLCHAIN}
31+
32+
WORKDIR /workspace/parser
33+
34+
# Build from an internal copy so Cargo and the build tasks cannot modify the
35+
# read-only source mount. Only the generated WASM artifacts are written out.
36+
CMD ["sh", "-ec", "cp -a /src /tmp/milo && cd /tmp/milo/parser && makers wasm && mkdir -p /output && cp -a /tmp/milo/dist/wasm/. /output/"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ISC License
2+
3+
Copyright (c) 2023, and above Paolo Insogna, NearForm and other contributors
4+
5+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

0 commit comments

Comments
 (0)