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

Function processResponse

deps/undici/src/lib/web/fetch/index.js:248–283  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

246 // given response being these substeps:
247
248 const processResponse = (response) => {
249 // 1. If locallyAborted is true, terminate these substeps.
250 if (locallyAborted) {
251 return
252 }
253
254 // 2. If response’s aborted flag is set, then:
255 if (response.aborted) {
256 // 1. Let deserializedError be the result of deserialize a serialized
257 // abort reason given controller’s serialized abort reason and
258 // relevantRealm.
259
260 // 2. Abort the fetch() call with p, request, responseObject, and
261 // deserializedError.
262
263 abortFetch(p, request, responseObject, controller.serializedAbortReason, controller.controller)
264 cleanupAbortListeners()
265 return
266 }
267
268 // 3. If response is a network error, then reject p with a TypeError
269 // and terminate these substeps.
270 if (response.type === 'error') {
271 p.reject(new TypeError('fetch failed', { cause: response.error }))
272 cleanupAbortListeners()
273 return
274 }
275
276 // 4. Set responseObject to the result of creating a Response object,
277 // given response, "immutable", and relevantRealm.
278 responseObject = new WeakRef(fromInnerResponse(response, 'immutable'))
279
280 // 5. Resolve p with responseObject.
281 p.resolve(responseObject.deref())
282 p = null
283 }
284
285 controller = fetching({
286 request,

Callers

nothing calls this directly

Calls 5

cleanupAbortListenersFunction · 0.85
rejectMethod · 0.80
abortFetchFunction · 0.70
fromInnerResponseFunction · 0.70
resolveMethod · 0.45

Tested by

no test coverage detected