MCPcopy Create free account
hub / github.com/nodejs/node / onResponseError

Function onResponseError

deps/undici/src/lib/web/fetch/index.js:2362–2384  ·  view source on GitHub ↗
(_controller, error)

Source from the content-addressed store, hash-verified

2360 },
2361
2362 onResponseError (_controller, error) {
2363 if (this.abort) {
2364 fetchParams.controller.off('terminated', this.abort)
2365 }
2366
2367 if (
2368 request.mode === 'websocket' &&
2369 allowH2 !== false &&
2370 error?.code === 'UND_ERR_INFO' &&
2371 error?.message === 'HTTP/2: Extended CONNECT protocol not supported by server'
2372 ) {
2373 // The origin negotiated H2, but RFC 8441 websocket support is unavailable.
2374 // Retry the opening handshake on a fresh HTTP/1.1-only connection instead.
2375 resolve(dispatchWithProtocolPreference(body, false))
2376 return
2377 }
2378
2379 this.body?.destroy(error)
2380
2381 fetchParams.controller.terminate(error)
2382
2383 reject(error)
2384 },
2385
2386 onRequestUpgrade (controller, status, headers, socket) {
2387 // We need to support 200 for websocket over h2 as per RFC-8441

Callers

nothing calls this directly

Calls 6

resolveFunction · 0.50
rejectFunction · 0.50
offMethod · 0.45
destroyMethod · 0.45
terminateMethod · 0.45

Tested by

no test coverage detected