diff --git a/lib/fetch/index.js b/lib/fetch/index.js index f69371a941d..2b7fe3632ea 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -320,7 +320,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') { // 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, initiatorType, globalThis, cacheState) + performance.markResourceTiming(timingInfo, originalURL.href, initiatorType, globalThis, cacheState) } } diff --git a/test/fetch/resource-timing.js b/test/fetch/resource-timing.js index 353f07f685b..25b3bcaafbb 100644 --- a/test/fetch/resource-timing.js +++ b/test/fetch/resource-timing.js @@ -13,22 +13,24 @@ const { const skip = nodeMajor < 18 || (nodeMajor === 18 && nodeMinor < 2) test('should create a PerformanceResourceTiming after each fetch request', { skip }, (t) => { - t.plan(6) + t.plan(8) const obs = new PerformanceObserver(list => { + const expectedResourceEntryName = `http://localhost:${server.address().port}/` + const entries = list.getEntries() t.equal(entries.length, 1) const [entry] = entries - t.same(entry.name, { - href: `http://localhost:${server.address().port}/`, - origin: `http://localhost:${server.address().port}`, - protocol: 'http' - }) + t.same(entry.name, expectedResourceEntryName) t.strictSame(entry.entryType, 'resource') t.ok(entry.duration >= 0) t.ok(entry.startTime >= 0) + const entriesByName = list.getEntriesByName(expectedResourceEntryName) + t.equal(entriesByName.length, 1) + t.strictSame(entriesByName[0], entry) + obs.disconnect() performance.clearResourceTimings() })