Skip to content

Commit 67b647e

Browse files
deps: update undici to 7.2.0
PR-URL: #56335 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent cef15f8 commit 67b647e

19 files changed

Lines changed: 1406 additions & 733 deletions

File tree

‎deps/undici/src/README.md‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,23 @@ stalls or deadlocks when running out of connections.
281281

282282
```js
283283
// Do
284-
constheaders=awaitfetch(url)
285-
.then(asyncres=> {
286-
forawait (constchunkofres.body) {
287-
// force consumption of body
288-
}
289-
returnres.headers
290-
})
284+
const { body, headers } =awaitfetch(url);
285+
forawait (constchunkofbody) {
286+
// force consumption of body
287+
}
291288

292289
// Do not
293-
constheaders=awaitfetch(url)
294-
.then(res=>res.headers)
290+
const { headers } =awaitfetch(url);
291+
```
292+
293+
The same applies for `request` too:
294+
```js
295+
// Do
296+
const { body, headers } =awaitrequest(url);
297+
awaitres.body.dump(); // force consumption of body
298+
299+
// Do not
300+
const { headers } =awaitrequest(url);
295301
```
296302

297303
However, if you want to get only headers, it might be better to use `HEAD` request method. Usage of this method will obviate the need for consumption or cancelling of the response body. See [MDN - HTTP - HTTP request methods - HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) for more details.
@@ -445,6 +451,16 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es
445451
*[__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
446452
*[__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
447453

454+
## Long Term Support
455+
456+
Undici aligns with the Node.js LTS schedule. The following table shows the supported versions:
457+
458+
| Version | Node.js | End of Life |
459+
|---------|-------------|-------------|
460+
| 5.x | v18.x | 2024-04-30 |
461+
| 6.x | v20.x v22.x | 2026-04-30 |
462+
| 7.x | v24.x | 2027-04-30 |
463+
448464
## License
449465

450466
MIT

‎deps/undici/src/docs/docs/api/ProxyAgent.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ Returns: `ProxyAgent`
1515
### Parameter: `ProxyAgentOptions`
1616

1717
Extends: [`AgentOptions`](/docs/docs/api/Agent.md#parameter-agentoptions)
18+
> It ommits `AgentOptions#connect`.
1819
1920
***uri**`string | URL` (required) - The URI of the proxy server. This can be provided as a string, as an instance of the URL class, or as an object with a `uri` property of type string.
2021
If the `uri` is provided as a string or `uri` is an object with an `uri` property of type string, then it will be parsed into a `URL` object according to the [WHATWG URL Specification](https://url.spec.whatwg.org).
2122
For detailed information on the parsing process and potential validation errors, please refer to the ["Writing" section](https://url.spec.whatwg.org/#writing) of the WHATWG URL Specification.
2223
***token**`string` (optional) - It can be passed by a string of token for authentication.
2324
***auth**`string` (**deprecated**) - Use token.
2425
***clientFactory**`(origin: URL, opts: Object) => Dispatcher` (optional) - Default: `(origin, opts) => new Pool(origin, opts)`
25-
***requestTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback).
26-
***proxyTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback).
26+
***requestTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
27+
***proxyTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
2728

2829
Examples:
2930

@@ -35,6 +36,13 @@ const proxyAgent = new ProxyAgent('my.proxy.server')
3536
constproxyAgent=newProxyAgent(newURL('my.proxy.server'))
3637
// or
3738
constproxyAgent=newProxyAgent({ uri:'my.proxy.server' })
39+
// or
40+
constproxyAgent=newProxyAgent({
41+
uri:newURL('my.proxy.server'),
42+
proxyTls: {
43+
signal:AbortSignal.timeout(1000)
44+
}
45+
})
3846
```
3947

4048
#### Example - Basic ProxyAgent instantiation

‎deps/undici/src/index.js‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,8 @@ module.exports.cacheStores = {
4949
MemoryCacheStore: require('./lib/cache/memory-cache-store')
5050
}
5151

52-
try{
53-
constSqliteCacheStore=require('./lib/cache/sqlite-cache-store')
54-
module.exports.cacheStores.SqliteCacheStore=SqliteCacheStore
55-
}catch(err){
56-
// Most likely node:sqlite was not present, since SqliteCacheStore is
57-
// optional, don't throw. Don't check specific error codes here because while
58-
// ERR_UNKNOWN_BUILTIN_MODULE is expected, users have seen other codes like
59-
// MODULE_NOT_FOUND
60-
}
52+
constSqliteCacheStore=require('./lib/cache/sqlite-cache-store')
53+
module.exports.cacheStores.SqliteCacheStore=SqliteCacheStore
6154

6255
module.exports.buildConnector=buildConnector
6356
module.exports.errors=errors

‎deps/undici/src/lib/cache/sqlite-cache-store.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict'
22

3-
const{ DatabaseSync }=require('node:sqlite')
43
const{ Writable }=require('stream')
54
const{ assertCacheKey, assertCacheValue }=require('../util/cache.js')
65

6+
letDatabaseSync
7+
78
constVERSION=3
89

910
// 2gb
@@ -101,6 +102,9 @@ module.exports = class SqliteCacheStore {
101102
}
102103
}
103104

105+
if(!DatabaseSync){
106+
DatabaseSync=require('node:sqlite').DatabaseSync
107+
}
104108
this.#db =newDatabaseSync(opts?.location??':memory:')
105109

106110
this.#db.exec(`

‎deps/undici/src/lib/dispatcher/client-h2.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const {
3030
kClosed,
3131
kBodyTimeout
3232
}=require('../core/symbols.js')
33+
const{ channels }=require('../core/diagnostics.js')
3334

3435
constkOpenStreams=Symbol('open streams')
3536

@@ -448,6 +449,14 @@ function writeH2 (client, request) {
448449

449450
session.ref()
450451

452+
if(channels.sendHeaders.hasSubscribers){
453+
letheader=''
454+
for(constkeyinheaders){
455+
header+=`${key}: ${headers[key]}\r\n`
456+
}
457+
channels.sendHeaders.publish({ request,headers: header,socket: session[kSocket]})
458+
}
459+
451460
// TODO(metcoder95): add support for sending trailers
452461
constshouldEndStream=method==='GET'||method==='HEAD'||body===null
453462
if(expectContinue){

0 commit comments

Comments
 (0)