Skip to content

Missing fields on Fetch PerformanceResourceTiming instance #2515

@Ethan-Arrowood

Description

@Ethan-Arrowood

Does anyone know why the PerformanceResourceTiming instance is missing information regarding DNS and what not?

Here is an example:

PerformanceResourceTiming {
    name: 'https://example.com/',
    entryType: 'resource',
    startTime: 257.69891691207886,
    duration: 98.86862516403198,
    initiatorType: 'fetch',
    nextHopProtocol: undefined,
    workerStart: 0,
    redirectStart: 0,
    redirectEnd: 0,
    fetchStart: 257.69891691207886,
    domainLookupStart: undefined,
    domainLookupEnd: undefined,
    connectStart: undefined,
    connectEnd: undefined,
    secureConnectionStart: undefined,
    requestStart: 0,
    responseStart: 0,
    responseEnd: 356.56754207611084,
    transferSize: 300,
    encodedBodySize: 0,
    decodedBodySize: 0
  }

That you get from a simple script like:

const url = new URL('https://example.com')
const res1 = await fetch(url);

await res1.text();

const fetchEntry = perfHooks.performance.getEntriesByName(url);
console.log(fetchEntry);

I tracked down the places in the source code where this gets created:

  1. undici/lib/fetch/index.js

    Lines 311 to 325 in 8422aa9

    markResourceTiming(
    timingInfo,
    originalURL,
    initiatorType,
    globalThis,
    cacheState
    )
    }
    // https://w3c.github.io/resource-timing/#dfn-mark-resource-timing
    function markResourceTiming (timingInfo, originalURL, initiatorType, globalThis, cacheState) {
    if (nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 2)) {
    performance.markResourceTiming(timingInfo, originalURL.href, initiatorType, globalThis, cacheState)
    }
    }
  2. https://github.com/nodejs/node/blob/main/lib/internal/perf/resource_timing.js#L205-L228

But it's still not immediately clear to me how to fix this. Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfetch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions