Skip to content

Commit 874f6c3

Browse files
nodejs-github-botjuanarbol
authored andcommittedJan 22, 2023
deps: update undici to 5.14.0
PR-URL: #45812 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 757a022 commit 874f6c3

File tree

16 files changed

+359
-137
lines changed

16 files changed

+359
-137
lines changed
 

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ Once you call `buildConnector`, it will return a connector function, which takes
2424
* **hostname** `string` (required)
2525
* **host** `string` (optional)
2626
* **protocol** `string` (required)
27-
* **port** `number` (required)
27+
* **port** `string` (required)
2828
* **servername** `string` (optional)
29+
* **localAddress** `string | null` (optional) Local address the socket should connect from.
30+
* **httpSocket** `Socket` (optional) Establish secure connection on a given socket rather than creating a new socket. It can only be sent on TLS update.
2931

3032
### Basic example
3133

‎deps/undici/src/lib/core/connect.js

+62-19
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,81 @@ const net = require('net')
44
const assert = require('assert')
55
const util = require('./util')
66
const { InvalidArgumentError, ConnectTimeoutError } = require('./errors')
7+
78
let tls // include tls conditionally since it is not always available
89

910
// TODO: session re-use does not wait for the first
1011
// connection to resolve the session and might therefore
1112
// resolve the same servername multiple times even when
1213
// re-use is enabled.
1314

15+
let SessionCache
16+
if (global.FinalizationRegistry) {
17+
SessionCache = class WeakSessionCache {
18+
constructor (maxCachedSessions) {
19+
this._maxCachedSessions = maxCachedSessions
20+
this._sessionCache = new Map()
21+
this._sessionRegistry = new global.FinalizationRegistry((key) => {
22+
if (this._sessionCache.size < this._maxCachedSessions) {
23+
return
24+
}
25+
26+
const ref = this._sessionCache.get(key)
27+
if (ref !== undefined && ref.deref() === undefined) {
28+
this._sessionCache.delete(key)
29+
}
30+
})
31+
}
32+
33+
get (sessionKey) {
34+
const ref = this._sessionCache.get(sessionKey)
35+
return ref ? ref.deref() : null
36+
}
37+
38+
set (sessionKey, session) {
39+
if (this._maxCachedSessions === 0) {
40+
return
41+
}
42+
43+
this._sessionCache.set(sessionKey, new WeakRef(session))
44+
this._sessionRegistry.register(session, sessionKey)
45+
}
46+
}
47+
} else {
48+
SessionCache = class SimpleSessionCache {
49+
constructor (maxCachedSessions) {
50+
this._maxCachedSessions = maxCachedSessions
51+
this._sessionCache = new Map()
52+
}
53+
54+
get (sessionKey) {
55+
return this._sessionCache.get(sessionKey)
56+
}
57+
58+
set (sessionKey, session) {
59+
if (this._maxCachedSessions === 0) {
60+
return
61+
}
62+
63+
if (this._sessionCache.size >= this._maxCachedSessions) {
64+
// remove the oldest session
65+
const { value: oldestKey } = this._sessionCache.keys().next()
66+
this._sessionCache.delete(oldestKey)
67+
}
68+
69+
this._sessionCache.set(sessionKey, session)
70+
}
71+
}
72+
}
73+
1474
function buildConnector ({ maxCachedSessions, socketPath, timeout, ...opts }) {
1575
if (maxCachedSessions != null && (!Number.isInteger(maxCachedSessions) || maxCachedSessions < 0)) {
1676
throw new InvalidArgumentError('maxCachedSessions must be a positive integer or zero')
1777
}
1878

1979
const options = { path: socketPath, ...opts }
20-
const sessionCache = new Map()
80+
const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions)
2181
timeout = timeout == null ? 10e3 : timeout
22-
maxCachedSessions = maxCachedSessions == null ? 100 : maxCachedSessions
2382

2483
return function connect ({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) {
2584
let socket
@@ -47,25 +106,9 @@ function buildConnector ({ maxCachedSessions, socketPath, timeout, ...opts }) {
47106

48107
socket
49108
.on('session', function (session) {
50-
// cache is disabled
51-
if (maxCachedSessions === 0) {
52-
return
53-
}
54-
55-
if (sessionCache.size >= maxCachedSessions) {
56-
// remove the oldest session
57-
const { value: oldestKey } = sessionCache.keys().next()
58-
sessionCache.delete(oldestKey)
59-
}
60-
109+
// TODO (fix): Can a session become invalid once established? Don't think so?
61110
sessionCache.set(sessionKey, session)
62111
})
63-
.on('error', function (err) {
64-
if (sessionKey && err.code !== 'UND_ERR_INFO') {
65-
// TODO (fix): Only delete for session related errors.
66-
sessionCache.delete(sessionKey)
67-
}
68-
})
69112
} else {
70113
assert(!httpSocket, 'httpSocket can only be sent on TLS update')
71114
socket = net.connect({

‎deps/undici/src/lib/fetch/body.js

+38-7
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ const { FormData } = require('./formdata')
77
const { kState } = require('./symbols')
88
const { webidl } = require('./webidl')
99
const { DOMException, structuredClone } = require('./constants')
10-
const { Blob } = require('buffer')
10+
const { Blob, File: NativeFile } = require('buffer')
1111
const { kBodyUsed } = require('../core/symbols')
1212
const assert = require('assert')
1313
const { isErrored } = require('../core/util')
1414
const { isUint8Array, isArrayBuffer } = require('util/types')
15-
const { File } = require('./file')
15+
const { File: UndiciFile } = require('./file')
1616
const { StringDecoder } = require('string_decoder')
1717
const { parseMIMEType, serializeAMimeType } = require('./dataURL')
1818

19-
/** @type {globalThis['ReadableStream']} */
20-
let ReadableStream
19+
let ReadableStream = globalThis.ReadableStream
20+
21+
/** @type {globalThis['File']} */
22+
const File = NativeFile ?? UndiciFile
2123

2224
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
2325
function extractBody (object, keepalive = false) {
@@ -142,7 +144,33 @@ function extractBody (object, keepalive = false) {
142144
source = object
143145

144146
// Set length to unclear, see html/6424 for improving this.
145-
// TODO
147+
length = (() => {
148+
const prefixLength = prefix.length
149+
const boundaryLength = boundary.length
150+
let bodyLength = 0
151+
152+
for (const [name, value] of object) {
153+
if (typeof value === 'string') {
154+
bodyLength +=
155+
prefixLength +
156+
Buffer.byteLength(`; name="${escape(normalizeLinefeeds(name))}"\r\n\r\n${normalizeLinefeeds(value)}\r\n`)
157+
} else {
158+
bodyLength +=
159+
prefixLength +
160+
Buffer.byteLength(`; name="${escape(normalizeLinefeeds(name))}"` + (value.name ? `; filename="${escape(value.name)}"` : '')) +
161+
2 + // \r\n
162+
`Content-Type: ${
163+
value.type || 'application/octet-stream'
164+
}\r\n\r\n`.length
165+
166+
// value is a Blob or File, and \r\n
167+
bodyLength += value.size + 2
168+
}
169+
}
170+
171+
bodyLength += boundaryLength + 4 // --boundary--
172+
return bodyLength
173+
})()
146174

147175
// Set type to `multipart/form-data; boundary=`,
148176
// followed by the multipart/form-data boundary string generated
@@ -348,7 +376,10 @@ function bodyMixinMethods (instance) {
348376
let busboy
349377

350378
try {
351-
busboy = Busboy({ headers })
379+
busboy = Busboy({
380+
headers,
381+
defParamCharset: 'utf8'
382+
})
352383
} catch (err) {
353384
// Error due to headers:
354385
throw Object.assign(new TypeError(), { cause: err })
@@ -361,7 +392,7 @@ function bodyMixinMethods (instance) {
361392
const { filename, encoding, mimeType } = info
362393
const chunks = []
363394

364-
if (encoding.toLowerCase() === 'base64') {
395+
if (encoding === 'base64' || encoding.toLowerCase() === 'base64') {
365396
let base64chunk = ''
366397

367398
value.on('data', (chunk) => {

‎deps/undici/src/lib/fetch/file.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { Blob } = require('buffer')
3+
const { Blob, File: NativeFile } = require('buffer')
44
const { types } = require('util')
55
const { kState } = require('./symbols')
66
const { isBlobLike } = require('./util')
@@ -329,11 +329,14 @@ function convertLineEndingsNative (s) {
329329
// rollup) will warn about circular dependencies. See:
330330
// https://github.com/nodejs/undici/issues/1629
331331
function isFileLike (object) {
332-
return object instanceof File || (
333-
object &&
334-
(typeof object.stream === 'function' ||
335-
typeof object.arrayBuffer === 'function') &&
336-
object[Symbol.toStringTag] === 'File'
332+
return (
333+
(NativeFile && object instanceof NativeFile) ||
334+
object instanceof File || (
335+
object &&
336+
(typeof object.stream === 'function' ||
337+
typeof object.arrayBuffer === 'function') &&
338+
object[Symbol.toStringTag] === 'File'
339+
)
337340
)
338341
}
339342

‎deps/undici/src/lib/fetch/formdata.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
const { isBlobLike, toUSVString, makeIterator } = require('./util')
44
const { kState } = require('./symbols')
5-
const { File, FileLike, isFileLike } = require('./file')
5+
const { File: UndiciFile, FileLike, isFileLike } = require('./file')
66
const { webidl } = require('./webidl')
7-
const { Blob } = require('buffer')
7+
const { Blob, File: NativeFile } = require('buffer')
8+
9+
/** @type {globalThis['File']} */
10+
const File = NativeFile ?? UndiciFile
811

912
// https://xhr.spec.whatwg.org/#formdata
1013
class FormData {

‎deps/undici/src/lib/fetch/headers.js

+22-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'use strict'
44

55
const { kHeadersList } = require('../core/symbols')
6-
const { kGuard } = require('./symbols')
6+
const { kGuard, kHeadersCaseInsensitive } = require('./symbols')
77
const { kEnumerableProperty } = require('../core/util')
88
const {
99
makeIterator,
@@ -96,27 +96,27 @@ class HeadersList {
9696

9797
// 1. If list contains name, then set name to the first such
9898
// header’s name.
99-
name = name.toLowerCase()
100-
const exists = this[kHeadersMap].get(name)
99+
const lowercaseName = name.toLowerCase()
100+
const exists = this[kHeadersMap].get(lowercaseName)
101101

102102
// 2. Append (name, value) to list.
103103
if (exists) {
104-
this[kHeadersMap].set(name, `${exists}, ${value}`)
104+
this[kHeadersMap].set(lowercaseName, { name: exists.name, value: `${exists.value}, ${value}` })
105105
} else {
106-
this[kHeadersMap].set(name, `${value}`)
106+
this[kHeadersMap].set(lowercaseName, { name, value })
107107
}
108108
}
109109

110110
// https://fetch.spec.whatwg.org/#concept-header-list-set
111111
set (name, value) {
112112
this[kHeadersSortedMap] = null
113-
name = name.toLowerCase()
113+
const lowercaseName = name.toLowerCase()
114114

115115
// 1. If list contains name, then set the value of
116116
// the first such header to value and remove the
117117
// others.
118118
// 2. Otherwise, append header (name, value) to list.
119-
return this[kHeadersMap].set(name, value)
119+
return this[kHeadersMap].set(lowercaseName, { name, value })
120120
}
121121

122122
// https://fetch.spec.whatwg.org/#concept-header-list-delete
@@ -137,14 +137,26 @@ class HeadersList {
137137
// 2. Return the values of all headers in list whose name
138138
// is a byte-case-insensitive match for name,
139139
// separated from each other by 0x2C 0x20, in order.
140-
return this[kHeadersMap].get(name.toLowerCase()) ?? null
140+
return this[kHeadersMap].get(name.toLowerCase())?.value ?? null
141141
}
142142

143143
* [Symbol.iterator] () {
144-
for (const pair of this[kHeadersMap]) {
145-
yield pair
144+
// use the lowercased name
145+
for (const [name, { value }] of this[kHeadersMap]) {
146+
yield [name, value]
146147
}
147148
}
149+
150+
get [kHeadersCaseInsensitive] () {
151+
/** @type {string[]} */
152+
const flatList = []
153+
154+
for (const { name, value } of this[kHeadersMap].values()) {
155+
flatList.push(name, value)
156+
}
157+
158+
return flatList
159+
}
148160
}
149161

150162
// https://fetch.spec.whatwg.org/#headers-class

‎deps/undici/src/lib/fetch/index.js

+27-17
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const {
3939
readableStreamClose,
4040
isomorphicEncode
4141
} = require('./util')
42-
const { kState, kHeaders, kGuard, kRealm } = require('./symbols')
42+
const { kState, kHeaders, kGuard, kRealm, kHeadersCaseInsensitive } = require('./symbols')
4343
const assert = require('assert')
4444
const { safelyExtractBody } = require('./body')
4545
const {
@@ -61,8 +61,7 @@ const { webidl } = require('./webidl')
6161

6262
/** @type {import('buffer').resolveObjectURL} */
6363
let resolveObjectURL
64-
/** @type {globalThis['ReadableStream']} */
65-
let ReadableStream
64+
let ReadableStream = globalThis.ReadableStream
6665

6766
const nodeVersion = process.versions.node.split('.')
6867
const nodeMajor = Number(nodeVersion[0])
@@ -781,8 +780,11 @@ async function mainFetch (fetchParams, recursive = false) {
781780
// https://fetch.spec.whatwg.org/#concept-scheme-fetch
782781
// given a fetch params fetchParams
783782
async function schemeFetch (fetchParams) {
783+
// Note: since the connection is destroyed on redirect, which sets fetchParams to a
784+
// cancelled state, we do not want this condition to trigger *unless* there have been
785+
// no redirects. See https://github.com/nodejs/undici/issues/1776
784786
// 1. If fetchParams is canceled, then return the appropriate network error for fetchParams.
785-
if (isCancelled(fetchParams)) {
787+
if (isCancelled(fetchParams) && fetchParams.request.redirectCount === 0) {
786788
return makeAppropriateNetworkError(fetchParams)
787789
}
788790

@@ -840,8 +842,8 @@ async function schemeFetch (fetchParams) {
840842
const response = makeResponse({
841843
statusText: 'OK',
842844
headersList: [
843-
['content-length', length],
844-
['content-type', type]
845+
['content-length', { name: 'Content-Length', value: length }],
846+
['content-type', { name: 'Content-Type', value: type }]
845847
]
846848
})
847849

@@ -870,7 +872,7 @@ async function schemeFetch (fetchParams) {
870872
return makeResponse({
871873
statusText: 'OK',
872874
headersList: [
873-
['content-type', mimeType]
875+
['content-type', { name: 'Content-Type', value: mimeType }]
874876
],
875877
body: safelyExtractBody(dataURLStruct.body)[0]
876878
})
@@ -1135,12 +1137,12 @@ async function httpRedirectFetch (fetchParams, response) {
11351137
return makeNetworkError('URL scheme must be a HTTP(S) scheme')
11361138
}
11371139

1138-
// 7. If request’s redirect count is twenty, return a network error.
1140+
// 7. If request’s redirect count is 20, then return a network error.
11391141
if (request.redirectCount === 20) {
11401142
return makeNetworkError('redirect count exceeded')
11411143
}
11421144

1143-
// 8. Increase request’s redirect count by one.
1145+
// 8. Increase request’s redirect count by 1.
11441146
request.redirectCount += 1
11451147

11461148
// 9. If request’s mode is "cors", locationURL includes credentials, and
@@ -1195,36 +1197,44 @@ async function httpRedirectFetch (fetchParams, response) {
11951197
}
11961198
}
11971199

1198-
// 13. If request’s body is non-null, then set request’s body to the first return
1200+
// 13. If request’s current URL’s origin is not same origin with locationURL’s
1201+
// origin, then for each headerName of CORS non-wildcard request-header name,
1202+
// delete headerName from request’s header list.
1203+
if (!sameOrigin(requestCurrentURL(request), locationURL)) {
1204+
// https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name
1205+
request.headersList.delete('authorization')
1206+
}
1207+
1208+
// 14. If request’s body is non-null, then set request’s body to the first return
11991209
// value of safely extracting request’s body’s source.
12001210
if (request.body != null) {
12011211
assert(request.body.source)
12021212
request.body = safelyExtractBody(request.body.source)[0]
12031213
}
12041214

1205-
// 14. Let timingInfo be fetchParams’s timing info.
1215+
// 15. Let timingInfo be fetchParams’s timing info.
12061216
const timingInfo = fetchParams.timingInfo
12071217

1208-
// 15. Set timingInfo’s redirect end time and post-redirect start time to the
1218+
// 16. Set timingInfo’s redirect end time and post-redirect start time to the
12091219
// coarsened shared current time given fetchParams’s cross-origin isolated
12101220
// capability.
12111221
timingInfo.redirectEndTime = timingInfo.postRedirectStartTime =
12121222
coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability)
12131223

1214-
// 16. If timingInfo’s redirect start time is 0, then set timingInfo’s
1224+
// 17. If timingInfo’s redirect start time is 0, then set timingInfo’s
12151225
// redirect start time to timingInfo’s start time.
12161226
if (timingInfo.redirectStartTime === 0) {
12171227
timingInfo.redirectStartTime = timingInfo.startTime
12181228
}
12191229

1220-
// 17. Append locationURL to request’s URL list.
1230+
// 18. Append locationURL to request’s URL list.
12211231
request.urlList.push(locationURL)
12221232

1223-
// 18. Invoke set request’s referrer policy on redirect on request and
1233+
// 19. Invoke set request’s referrer policy on redirect on request and
12241234
// actualResponse.
12251235
setRequestReferrerPolicyOnRedirect(request, actualResponse)
12261236

1227-
// 19. Return the result of running main fetch given fetchParams and true.
1237+
// 20. Return the result of running main fetch given fetchParams and true.
12281238
return mainFetch(fetchParams, true)
12291239
}
12301240

@@ -1930,7 +1940,7 @@ async function httpNetworkFetch (
19301940
origin: url.origin,
19311941
method: request.method,
19321942
body: fetchParams.controller.dispatcher.isMockActive ? request.body && request.body.source : body,
1933-
headers: [...request.headersList].flat(),
1943+
headers: request.headersList[kHeadersCaseInsensitive],
19341944
maxRedirections: 0,
19351945
bodyTimeout: 300_000,
19361946
headersTimeout: 300_000

‎deps/undici/src/lib/fetch/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const { URLSerializer } = require('./dataURL')
2929
const { kHeadersList } = require('../core/symbols')
3030
const assert = require('assert')
3131

32-
let TransformStream
32+
let TransformStream = globalThis.TransformStream
3333

3434
const kInit = Symbol('init')
3535

‎deps/undici/src/lib/fetch/response.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ function makeAppropriateNetworkError (fetchParams) {
436436
// otherwise return a network error.
437437
return isAborted(fetchParams)
438438
? makeNetworkError(new DOMException('The operation was aborted.', 'AbortError'))
439-
: makeNetworkError(fetchParams.controller.terminated.reason)
439+
: makeNetworkError('Request was cancelled.')
440440
}
441441

442442
// https://whatpr.org/fetch/1392.html#initialize-a-response

‎deps/undici/src/lib/fetch/symbols.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ module.exports = {
66
kSignal: Symbol('signal'),
77
kState: Symbol('state'),
88
kGuard: Symbol('guard'),
9-
kRealm: Symbol('realm')
9+
kRealm: Symbol('realm'),
10+
kHeadersCaseInsensitive: Symbol('headers case insensitive')
1011
}

‎deps/undici/src/lib/fetch/util.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,8 @@ function isReadableStreamLike (stream) {
863863
)
864864
}
865865

866+
const MAXIMUM_ARGUMENT_LENGTH = 65535
867+
866868
/**
867869
* @see https://infra.spec.whatwg.org/#isomorphic-decode
868870
* @param {number[]|Uint8Array} input
@@ -871,13 +873,12 @@ function isomorphicDecode (input) {
871873
// 1. To isomorphic decode a byte sequence input, return a string whose code point
872874
// length is equal to input’s length and whose code points have the same values
873875
// as the values of input’s bytes, in the same order.
874-
let output = ''
875876

876-
for (let i = 0; i < input.length; i++) {
877-
output += String.fromCharCode(input[i])
877+
if (input.length < MAXIMUM_ARGUMENT_LENGTH) {
878+
return String.fromCharCode(...input)
878879
}
879880

880-
return output
881+
return input.reduce((previous, current) => previous + String.fromCharCode(current), '')
881882
}
882883

883884
/**

‎deps/undici/src/lib/fileapi/filereader.js

+30
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,13 @@ class FileReader extends EventTarget {
182182
set onloadend (fn) {
183183
webidl.brandCheck(this, FileReader)
184184

185+
if (this[kEvents].loadend) {
186+
this.removeEventListener('loadend', this[kEvents].loadend)
187+
}
188+
185189
if (typeof fn === 'function') {
186190
this[kEvents].loadend = fn
191+
this.addEventListener('loadend', fn)
187192
} else {
188193
this[kEvents].loadend = null
189194
}
@@ -198,8 +203,13 @@ class FileReader extends EventTarget {
198203
set onerror (fn) {
199204
webidl.brandCheck(this, FileReader)
200205

206+
if (this[kEvents].error) {
207+
this.removeEventListener('error', this[kEvents].error)
208+
}
209+
201210
if (typeof fn === 'function') {
202211
this[kEvents].error = fn
212+
this.addEventListener('error', fn)
203213
} else {
204214
this[kEvents].error = null
205215
}
@@ -214,8 +224,13 @@ class FileReader extends EventTarget {
214224
set onloadstart (fn) {
215225
webidl.brandCheck(this, FileReader)
216226

227+
if (this[kEvents].loadstart) {
228+
this.removeEventListener('loadstart', this[kEvents].loadstart)
229+
}
230+
217231
if (typeof fn === 'function') {
218232
this[kEvents].loadstart = fn
233+
this.addEventListener('loadstart', fn)
219234
} else {
220235
this[kEvents].loadstart = null
221236
}
@@ -230,8 +245,13 @@ class FileReader extends EventTarget {
230245
set onprogress (fn) {
231246
webidl.brandCheck(this, FileReader)
232247

248+
if (this[kEvents].progress) {
249+
this.removeEventListener('progress', this[kEvents].progress)
250+
}
251+
233252
if (typeof fn === 'function') {
234253
this[kEvents].progress = fn
254+
this.addEventListener('progress', fn)
235255
} else {
236256
this[kEvents].progress = null
237257
}
@@ -246,8 +266,13 @@ class FileReader extends EventTarget {
246266
set onload (fn) {
247267
webidl.brandCheck(this, FileReader)
248268

269+
if (this[kEvents].load) {
270+
this.removeEventListener('load', this[kEvents].load)
271+
}
272+
249273
if (typeof fn === 'function') {
250274
this[kEvents].load = fn
275+
this.addEventListener('load', fn)
251276
} else {
252277
this[kEvents].load = null
253278
}
@@ -262,8 +287,13 @@ class FileReader extends EventTarget {
262287
set onabort (fn) {
263288
webidl.brandCheck(this, FileReader)
264289

290+
if (this[kEvents].abort) {
291+
this.removeEventListener('abort', this[kEvents].abort)
292+
}
293+
265294
if (typeof fn === 'function') {
266295
this[kEvents].abort = fn
296+
this.addEventListener('abort', fn)
267297
} else {
268298
this[kEvents].abort = null
269299
}

‎deps/undici/src/lib/fileapi/util.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,19 @@ function readOperation (fr, blob, type, encodingName) {
191191

192192
/**
193193
* @see https://w3c.github.io/FileAPI/#fire-a-progress-event
194+
* @see https://dom.spec.whatwg.org/#concept-event-fire
194195
* @param {string} e The name of the event
195196
* @param {import('./filereader').FileReader} reader
196197
*/
197198
function fireAProgressEvent (e, reader) {
199+
// The progress event e does not bubble. e.bubbles must be false
200+
// The progress event e is NOT cancelable. e.cancelable must be false
198201
const event = new ProgressEvent(e, {
199202
bubbles: false,
200203
cancelable: false
201204
})
202205

203206
reader.dispatchEvent(event)
204-
try {
205-
// eslint-disable-next-line no-useless-call
206-
reader[`on${e}`]?.call(reader, event)
207-
} catch (err) {
208-
// Prevent the error from being swallowed
209-
queueMicrotask(() => {
210-
throw err
211-
})
212-
}
213207
}
214208

215209
/**

‎deps/undici/src/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "undici",
3-
"version": "5.13.0",
3+
"version": "5.14.0",
44
"description": "An HTTP/1.1 client, written from scratch for Node.js",
55
"homepage": "https://undici.nodejs.org",
66
"bugs": {
@@ -89,12 +89,12 @@
8989
"proxy": "^1.0.2",
9090
"proxyquire": "^2.1.3",
9191
"semver": "^7.3.5",
92-
"sinon": "^14.0.0",
92+
"sinon": "^15.0.0",
9393
"snazzy": "^9.0.0",
9494
"standard": "^17.0.0",
9595
"table": "^6.8.0",
9696
"tap": "^16.1.0",
97-
"tsd": "^0.24.1",
97+
"tsd": "^0.25.0",
9898
"typescript": "^4.8.4",
9999
"wait-on": "^6.0.0"
100100
},

‎deps/undici/src/types/connector.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ declare namespace buildConnector {
1616
hostname: string
1717
host?: string
1818
protocol: string
19-
port: number
19+
port: string
2020
servername?: string
21+
localAddress?: string | null
22+
httpSocket?: Socket
2123
}
2224

2325
export type Callback = (...args: CallbackArgs) => void

‎deps/undici/undici.js

+145-55
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.