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

Function finalizeAndReportTiming

deps/undici/src/lib/web/fetch/index.js:303–365  ·  view source on GitHub ↗
(response, initiatorType = 'other')

Source from the content-addressed store, hash-verified

301
302// https://fetch.spec.whatwg.org/#finalize-and-report-timing
303function finalizeAndReportTiming (response, initiatorType = 'other') {
304 // 1. If response is an aborted network error, then return.
305 if (response.type === 'error' && response.aborted) {
306 return
307 }
308
309 // 2. If response’s URL list is null or empty, then return.
310 if (!response.urlList?.length) {
311 return
312 }
313
314 // 3. Let originalURL be response’s URL list[0].
315 const originalURL = response.urlList[0]
316
317 // 4. Let timingInfo be response’s timing info.
318 let timingInfo = response.timingInfo
319
320 // 5. Let cacheState be response’s cache state.
321 let cacheState = response.cacheState
322
323 // 6. If originalURL’s scheme is not an HTTP(S) scheme, then return.
324 if (!urlIsHttpHttpsScheme(originalURL)) {
325 return
326 }
327
328 // 7. If timingInfo is null, then return.
329 if (timingInfo === null) {
330 return
331 }
332
333 // 8. If response’s timing allow passed flag is not set, then:
334 if (!response.timingAllowPassed) {
335 // 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo.
336 timingInfo = createOpaqueTimingInfo({
337 startTime: timingInfo.startTime
338 })
339
340 // 2. Set cacheState to the empty string.
341 cacheState = ''
342 }
343
344 // 9. Set timingInfo’s end time to the coarsened shared current time
345 // given global’s relevant settings object’s cross-origin isolated
346 // capability.
347 // TODO: given global’s relevant settings object’s cross-origin isolated
348 // capability?
349 timingInfo.endTime = coarsenedSharedCurrentTime()
350
351 // 10. Set response’s timing info to timingInfo.
352 response.timingInfo = timingInfo
353
354 // 11. Mark resource timing for timingInfo, originalURL, initiatorType,
355 // global, and cacheState.
356 markResourceTiming(
357 timingInfo,
358 originalURL.href,
359 initiatorType,
360 globalThis,

Callers 1

handleFetchDoneFunction · 0.70

Calls 4

markResourceTimingFunction · 0.85
urlIsHttpHttpsSchemeFunction · 0.70
createOpaqueTimingInfoFunction · 0.70

Tested by

no test coverage detected