Skip to content

Commit 47b80c2

Browse files
deps: update undici to 7.0.0
PR-URL: #56070 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Matthew Aitken <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent d5d1e80 commit 47b80c2

File tree

175 files changed

+15862
-19700
lines changed

Some content is hidden

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

175 files changed

+15862
-19700
lines changed

deps/undici/src/CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* [Releases](#releases)
99
* [Update `WPTs`](#update-wpts)
1010
* [Building for externally shared node builtins](#external-builds)
11-
* [Benchmarks](#benchmarks
11+
* [Benchmarks](#benchmarks)
1212
* [Documentation](#documentation)
1313
* [Developer's Certificate of Origin 1.1](#developers-certificate-of-origin)
1414
* [Moderation Policy](#moderation-policy)
@@ -104,7 +104,6 @@ git node wpt resources
104104
git node wpt interfaces
105105
git node wpt common
106106
git node wpt fetch
107-
git node wpt FileAPI
108107
git node wpt xhr
109108
git node wpt websockets
110109
git node wpt mimesniff

deps/undici/src/GOVERNANCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ request or issue. The WG should serve as the final arbiter where
5050
required.
5151

5252
For the current list of Collaborators, see the project
53-
[README.md](./README.md#collaborators). The list shall be in an
53+
[README.md](./README.md#collaborators). The list should be in
5454
alphabetical order.
5555

5656
### WG Membership

deps/undici/src/README.md

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# undici
22

3-
[![Node CI](https://github.com/nodejs/undici/actions/workflows/nodejs.yml/badge.svg)](https://github.com/nodejs/undici/actions/workflows/nodejs.yml) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![npm version](https://badge.fury.io/js/undici.svg)](https://badge.fury.io/js/undici) [![codecov](https://codecov.io/gh/nodejs/undici/branch/main/graph/badge.svg?token=yZL6LtXkOA)](https://codecov.io/gh/nodejs/undici)
3+
[![Node CI](https://github.com/nodejs/undici/actions/workflows/nodejs.yml/badge.svg)](https://github.com/nodejs/undici/actions/workflows/nodejs.yml) [![neostandard javascript style](https://img.shields.io/badge/neo-standard-7fffff?style=flat\&labelColor=ff80ff)](https://github.com/neostandard/neostandard) [![npm version](https://badge.fury.io/js/undici.svg)](https://badge.fury.io/js/undici) [![codecov](https://codecov.io/gh/nodejs/undici/branch/main/graph/badge.svg?token=yZL6LtXkOA)](https://codecov.io/gh/nodejs/undici)
44

55
An HTTP/1.1 client, written from scratch for Node.js.
66

@@ -22,41 +22,26 @@ npm i undici
2222
## Benchmarks
2323

2424
The benchmark is a simple getting data [example](https://github.com/nodejs/undici/blob/main/benchmarks/benchmark.js) using a
25-
50 TCP connections with a pipelining depth of 10 running on Node 20.10.0.
26-
27-
| _Tests_ | _Samples_ | _Result_ | _Tolerance_ | _Difference with slowest_ |
28-
| :-----------------: | :-------: | :--------------: | :---------: | :-----------------------: |
29-
| undici - fetch | 30 | 3704.43 req/sec | ± 2.95 % | - |
30-
| http - no keepalive | 20 | 4275.30 req/sec | ± 2.60 % | + 15.41 % |
31-
| node-fetch | 10 | 4759.42 req/sec | ± 0.87 % | + 28.48 % |
32-
| request | 40 | 4803.37 req/sec | ± 2.77 % | + 29.67 % |
33-
| axios | 45 | 4951.97 req/sec | ± 2.88 % | + 33.68 % |
34-
| got | 10 | 5969.67 req/sec | ± 2.64 % | + 61.15 % |
35-
| superagent | 10 | 9471.48 req/sec | ± 1.50 % | + 155.68 % |
36-
| http - keepalive | 25 | 10327.49 req/sec | ± 2.95 % | + 178.79 % |
37-
| undici - pipeline | 10 | 15053.41 req/sec | ± 1.63 % | + 306.36 % |
38-
| undici - request | 10 | 19264.24 req/sec | ± 1.74 % | + 420.03 % |
39-
| undici - stream | 15 | 20317.29 req/sec | ± 2.13 % | + 448.46 % |
40-
| undici - dispatch | 10 | 24883.28 req/sec | ± 1.54 % | + 571.72 % |
41-
42-
The benchmark is a simple sending data [example](https://github.com/nodejs/undici/blob/main/benchmarks/post-benchmark.js) using a
43-
50 TCP connections with a pipelining depth of 10 running on Node 20.10.0.
44-
45-
| _Tests_ | _Samples_ | _Result_ | _Tolerance_ | _Difference with slowest_ |
46-
| :-----------------: | :-------: | :-------------: | :---------: | :-----------------------: |
47-
| undici - fetch | 20 | 1968.42 req/sec | ± 2.63 % | - |
48-
| http - no keepalive | 25 | 2330.30 req/sec | ± 2.99 % | + 18.38 % |
49-
| node-fetch | 20 | 2485.36 req/sec | ± 2.70 % | + 26.26 % |
50-
| got | 15 | 2787.68 req/sec | ± 2.56 % | + 41.62 % |
51-
| request | 30 | 2805.10 req/sec | ± 2.59 % | + 42.50 % |
52-
| axios | 10 | 3040.45 req/sec | ± 1.72 % | + 54.46 % |
53-
| superagent | 20 | 3358.29 req/sec | ± 2.51 % | + 70.61 % |
54-
| http - keepalive | 20 | 3477.94 req/sec | ± 2.51 % | + 76.69 % |
55-
| undici - pipeline | 25 | 3812.61 req/sec | ± 2.80 % | + 93.69 % |
56-
| undici - request | 10 | 6067.00 req/sec | ± 0.94 % | + 208.22 % |
57-
| undici - stream | 10 | 6391.61 req/sec | ± 1.98 % | + 224.71 % |
58-
| undici - dispatch | 10 | 6397.00 req/sec | ± 1.48 % | + 224.98 % |
25+
50 TCP connections with a pipelining depth of 10 running on Node 22.11.0.
5926

27+
```
28+
┌────────────────────────┬─────────┬────────────────────┬────────────┬─────────────────────────┐
29+
│ Tests │ Samples │ Result │ Tolerance │ Difference with slowest │
30+
├────────────────────────┼─────────┼────────────────────┼────────────┼─────────────────────────┤
31+
│ 'axios' │ 15 │ '5708.26 req/sec' │ '± 2.91 %' │ '-' │
32+
│ 'http - no keepalive' │ 10 │ '5809.80 req/sec' │ '± 2.30 %' │ '+ 1.78 %' │
33+
│ 'request' │ 30 │ '5828.80 req/sec' │ '± 2.91 %' │ '+ 2.11 %' │
34+
│ 'undici - fetch' │ 40 │ '5903.78 req/sec' │ '± 2.87 %' │ '+ 3.43 %' │
35+
│ 'node-fetch' │ 10 │ '5945.40 req/sec' │ '± 2.13 %' │ '+ 4.15 %' │
36+
│ 'got' │ 35 │ '6511.45 req/sec' │ '± 2.84 %' │ '+ 14.07 %' │
37+
│ 'http - keepalive' │ 65 │ '9193.24 req/sec' │ '± 2.92 %' │ '+ 61.05 %' │
38+
│ 'superagent' │ 35 │ '9339.43 req/sec' │ '± 2.95 %' │ '+ 63.61 %' │
39+
│ 'undici - pipeline' │ 50 │ '13364.62 req/sec' │ '± 2.93 %' │ '+ 134.13 %' │
40+
│ 'undici - stream' │ 95 │ '18245.36 req/sec' │ '± 2.99 %' │ '+ 219.63 %' │
41+
│ 'undici - request' │ 50 │ '18340.17 req/sec' │ '± 2.84 %' │ '+ 221.29 %' │
42+
│ 'undici - dispatch' │ 40 │ '22234.42 req/sec' │ '± 2.94 %' │ '+ 289.51 %' │
43+
└────────────────────────┴─────────┴────────────────────┴────────────┴─────────────────────────┘
44+
```
6045

6146
## Quick Start
6247

@@ -127,13 +112,12 @@ Arguments:
127112
* **options** [`RequestOptions`](./docs/docs/api/Dispatcher.md#parameter-requestoptions)
128113
* **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
129114
* **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
130-
* **maxRedirections** `Integer` - Default: `0`
131115

132116
Returns a promise with the result of the `Dispatcher.request` method.
133117

134118
Calls `options.dispatcher.request(options)`.
135119

136-
See [Dispatcher.request](./docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback) for more details, and [request examples](./examples/README.md) for examples.
120+
See [Dispatcher.request](./docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback) for more details, and [request examples](./docs/examples/README.md) for examples.
137121

138122
### `undici.stream([url, options, ]factory): Promise`
139123

@@ -143,7 +127,6 @@ Arguments:
143127
* **options** [`StreamOptions`](./docs/docs/api/Dispatcher.md#parameter-streamoptions)
144128
* **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
145129
* **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
146-
* **maxRedirections** `Integer` - Default: `0`
147130
* **factory** `Dispatcher.stream.factory`
148131

149132
Returns a promise with the result of the `Dispatcher.stream` method.
@@ -160,7 +143,6 @@ Arguments:
160143
* **options** [`PipelineOptions`](./docs/docs/api/Dispatcher.md#parameter-pipelineoptions)
161144
* **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
162145
* **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
163-
* **maxRedirections** `Integer` - Default: `0`
164146
* **handler** `Dispatcher.pipeline.handler`
165147

166148
Returns: `stream.Duplex`
@@ -178,7 +160,6 @@ Arguments:
178160
* **url** `string | URL | UrlObject`
179161
* **options** [`ConnectOptions`](./docs/docs/api/Dispatcher.md#parameter-connectoptions)
180162
* **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
181-
* **maxRedirections** `Integer` - Default: `0`
182163
* **callback** `(err: Error | null, data: ConnectData | null) => void` (optional)
183164

184165
Returns a promise with the result of the `Dispatcher.connect` method.
@@ -234,7 +215,7 @@ A body can be of the following types:
234215
- URLSearchParams
235216
- FormData
236217

237-
In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard.](https://fetch.spec.whatwg.org)
218+
In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard](https://fetch.spec.whatwg.org).
238219

239220
```js
240221
import { fetch } from 'undici'
@@ -263,13 +244,13 @@ await fetch('http://example.com', { method: 'POST', body })
263244

264245
#### `request.duplex`
265246

266-
- half
247+
- `'half'`
267248

268-
In this implementation of fetch, `request.duplex` must be set if `request.body` is `ReadableStream` or `Async Iterables`, however, fetch requests are currently always full duplex. For more detail refer to the [Fetch Standard.](https://fetch.spec.whatwg.org/#dom-requestinit-duplex).
249+
In this implementation of fetch, `request.duplex` must be set if `request.body` is `ReadableStream` or `Async Iterables`, however, even though the value must be set to `'half'`, it is actually a _full_ duplex. For more detail refer to the [Fetch Standard](https://fetch.spec.whatwg.org/#dom-requestinit-duplex).
269250

270251
#### `response.body`
271252

272-
Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
253+
Nodejs has two kinds of streams: [web streams](https://nodejs.org/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
273254

274255
```js
275256
import { fetch } from 'undici'
@@ -338,7 +319,6 @@ Arguments:
338319
* **url** `string | URL | UrlObject`
339320
* **options** [`UpgradeOptions`](./docs/docs/api/Dispatcher.md#parameter-upgradeoptions)
340321
* **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
341-
* **maxRedirections** `Integer` - Default: `0`
342322
* **callback** `(error: Error | null, data: UpgradeData) => void` (optional)
343323

344324
Returns a promise with the result of the `Dispatcher.upgrade` method.
@@ -407,7 +387,8 @@ Refs: https://tools.ietf.org/html/rfc7231#section-5.1.1
407387
### Pipelining
408388

409389
Undici will only use pipelining if configured with a `pipelining` factor
410-
greater than `1`.
390+
greater than `1`. Also it is important to pass `blocking: false` to the
391+
request options to properly pipeline requests.
411392

412393
Undici always assumes that connections are persistent and will immediately
413394
pipeline requests, without checking whether the connection is persistent.

deps/undici/src/build/Dockerfile

Lines changed: 0 additions & 25 deletions
This file was deleted.

deps/undici/src/build/wasm.js

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict'
22

3+
const WASM_BUILDER_CONTAINER = 'ghcr.io/nodejs/wasm-builder@sha256:975f391d907e42a75b8c72eb77c782181e941608687d4d8694c3e9df415a0970' // v0.0.9
4+
35
const { execSync } = require('node:child_process')
46
const { writeFileSync, readFileSync } = require('node:fs')
57
const { join, resolve } = require('node:path')
68

79
const ROOT = resolve(__dirname, '../')
810
const WASM_SRC = resolve(__dirname, '../deps/llhttp')
911
const WASM_OUT = resolve(__dirname, '../lib/llhttp')
10-
const DOCKERFILE = resolve(__dirname, './Dockerfile')
1112

1213
// These are defined by build environment
1314
const WASM_CC = process.env.WASM_CC || 'clang'
@@ -33,7 +34,17 @@ const writeWasmChunk = (path, dest) => {
3334
3435
const { Buffer } = require('node:buffer')
3536
36-
module.exports = Buffer.from('${base64}', 'base64')
37+
const wasmBase64 = '${base64}'
38+
39+
let wasmBuffer
40+
41+
Object.defineProperty(module, 'exports', {
42+
get: () => {
43+
return wasmBuffer
44+
? wasmBuffer
45+
: (wasmBuffer = Buffer.from(wasmBase64, 'base64'))
46+
}
47+
})
3748
`)
3849
}
3950

@@ -42,33 +53,16 @@ if (!platform && process.argv[2]) {
4253
platform = execSync('docker info -f "{{.OSType}}/{{.Architecture}}"').toString().trim()
4354
}
4455

45-
if (process.argv[2] === '--rm') {
46-
const cmd = 'docker image rm llhttp_wasm_builder'
47-
48-
console.log(`> ${cmd}\n\n`)
49-
try {
50-
execSync(cmd, { stdio: 'inherit' })
51-
} catch (e) {}
52-
53-
process.exit(0)
54-
}
55-
56-
if (process.argv[2] === '--prebuild') {
57-
const cmd = `docker build --platform=${platform.toString().trim()} -t llhttp_wasm_builder -f ${DOCKERFILE} ${ROOT}`
58-
59-
console.log(`> ${cmd}\n\n`)
60-
execSync(cmd, { stdio: 'inherit' })
61-
62-
process.exit(0)
63-
}
64-
6556
if (process.argv[2] === '--docker') {
66-
let cmd = `docker run --rm -t --platform=${platform.toString().trim()}`
57+
let cmd = `docker run --rm --platform=${platform.toString().trim()} `
6758
if (process.platform === 'linux') {
6859
cmd += ` --user ${process.getuid()}:${process.getegid()}`
6960
}
7061

71-
cmd += ` --mount type=bind,source=${ROOT}/lib/llhttp,target=/home/node/undici/lib/llhttp llhttp_wasm_builder node build/wasm.js`
62+
cmd += ` --mount type=bind,source=${ROOT}/lib/llhttp,target=/home/node/build/lib/llhttp \
63+
--mount type=bind,source=${ROOT}/build,target=/home/node/build/build \
64+
--mount type=bind,source=${ROOT}/deps,target=/home/node/build/deps \
65+
-t ${WASM_BUILDER_CONTAINER} node build/wasm.js`
7266
console.log(`> ${cmd}\n\n`)
7367
execSync(cmd, { stdio: 'inherit' })
7468
process.exit(0)

0 commit comments

Comments
 (0)