NPM Update / fix
This commit is contained in:
48
node_modules/undici/lib/client.js
generated
vendored
48
node_modules/undici/lib/client.js
generated
vendored
@ -917,11 +917,9 @@ class Parser {
|
||||
socket[kReset] = true
|
||||
}
|
||||
|
||||
let pause
|
||||
try {
|
||||
pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false
|
||||
} catch (err) {
|
||||
util.destroy(socket, err)
|
||||
const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false
|
||||
|
||||
if (request.aborted) {
|
||||
return -1
|
||||
}
|
||||
|
||||
@ -968,13 +966,8 @@ class Parser {
|
||||
|
||||
this.bytesRead += buf.length
|
||||
|
||||
try {
|
||||
if (request.onData(buf) === false) {
|
||||
return constants.ERROR.PAUSED
|
||||
}
|
||||
} catch (err) {
|
||||
util.destroy(socket, err)
|
||||
return -1
|
||||
if (request.onData(buf) === false) {
|
||||
return constants.ERROR.PAUSED
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,11 +1008,7 @@ class Parser {
|
||||
return -1
|
||||
}
|
||||
|
||||
try {
|
||||
request.onComplete(headers)
|
||||
} catch (err) {
|
||||
errorRequest(client, request, err)
|
||||
}
|
||||
request.onComplete(headers)
|
||||
|
||||
client[kQueue][client[kRunningIdx]++] = null
|
||||
|
||||
@ -1183,7 +1172,7 @@ async function connect (client) {
|
||||
const idx = hostname.indexOf(']')
|
||||
|
||||
assert(idx !== -1)
|
||||
const ip = hostname.substr(1, idx - 1)
|
||||
const ip = hostname.substring(1, idx)
|
||||
|
||||
assert(net.isIP(ip))
|
||||
hostname = ip
|
||||
@ -1682,6 +1671,7 @@ function writeH2 (client, session, request) {
|
||||
return false
|
||||
}
|
||||
|
||||
/** @type {import('node:http2').ClientHttp2Stream} */
|
||||
let stream
|
||||
const h2State = client[kHTTP2SessionState]
|
||||
|
||||
@ -1777,14 +1767,10 @@ function writeH2 (client, session, request) {
|
||||
const shouldEndStream = method === 'GET' || method === 'HEAD'
|
||||
if (expectContinue) {
|
||||
headers[HTTP2_HEADER_EXPECT] = '100-continue'
|
||||
/**
|
||||
* @type {import('node:http2').ClientHttp2Stream}
|
||||
*/
|
||||
stream = session.request(headers, { endStream: shouldEndStream, signal })
|
||||
|
||||
stream.once('continue', writeBodyH2)
|
||||
} else {
|
||||
/** @type {import('node:http2').ClientHttp2Stream} */
|
||||
stream = session.request(headers, {
|
||||
endStream: shouldEndStream,
|
||||
signal
|
||||
@ -1796,7 +1782,9 @@ function writeH2 (client, session, request) {
|
||||
++h2State.openStreams
|
||||
|
||||
stream.once('response', headers => {
|
||||
if (request.onHeaders(Number(headers[HTTP2_HEADER_STATUS]), headers, stream.resume.bind(stream), '') === false) {
|
||||
const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers
|
||||
|
||||
if (request.onHeaders(Number(statusCode), realHeaders, stream.resume.bind(stream), '') === false) {
|
||||
stream.pause()
|
||||
}
|
||||
})
|
||||
@ -1806,13 +1794,17 @@ function writeH2 (client, session, request) {
|
||||
})
|
||||
|
||||
stream.on('data', (chunk) => {
|
||||
if (request.onData(chunk) === false) stream.pause()
|
||||
if (request.onData(chunk) === false) {
|
||||
stream.pause()
|
||||
}
|
||||
})
|
||||
|
||||
stream.once('close', () => {
|
||||
h2State.openStreams -= 1
|
||||
// TODO(HTTP/2): unref only if current streams count is 0
|
||||
if (h2State.openStreams === 0) session.unref()
|
||||
if (h2State.openStreams === 0) {
|
||||
session.unref()
|
||||
}
|
||||
})
|
||||
|
||||
stream.once('error', function (err) {
|
||||
@ -1972,7 +1964,11 @@ function writeStream ({ h2stream, body, client, request, socket, contentLength,
|
||||
}
|
||||
}
|
||||
const onAbort = function () {
|
||||
onFinished(new RequestAbortedError())
|
||||
if (finished) {
|
||||
return
|
||||
}
|
||||
const err = new RequestAbortedError()
|
||||
queueMicrotask(() => onFinished(err))
|
||||
}
|
||||
const onFinished = function (err) {
|
||||
if (finished) {
|
||||
|
Reference in New Issue
Block a user