nodejs / nodejs/undici

Missing fields on Fetch PerformanceResourceTiming instance

Open
#2,515 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug fetch
Dominant language
JavaScript
Stars
7.7k
Forks
880
Avg merge
2d 16h
Merged PRs (30d)
68

Description

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. https://github.com/nodejs/undici/blob/8422aa988243fb4c6c37b78519954d7337cc240b/lib/fetch/index.js#L311-L325
  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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied fetch example, then read the resource timing creation paths in undici/lib/fetch/index.js and Node.js lib/internal/perf/resource_timing.js at the linked locations. Compare the populated and undefined timing fields with the expected PerformanceResourceTiming behavior; done means the missing DNS and connection timing information is correctly represented or its limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.