Skip to content

Commit 71c3605

Browse files
authored
fix: correctly calculate resource timing duration (#1988)
1 parent 4885b11 commit 71c3605

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/fetch/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
297297
// capability.
298298
// TODO: given global’s relevant settings object’s cross-origin isolated
299299
// capability?
300-
response.timingInfo.endTime = coarsenedSharedCurrentTime()
300+
timingInfo.endTime = coarsenedSharedCurrentTime()
301301

302302
// 10. Set response’s timing info to timingInfo.
303303
response.timingInfo = timingInfo

test/fetch/resource-timing.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
const skip = nodeMajor < 18 || (nodeMajor === 18 && nodeMinor < 2)
1414

1515
test('should create a PerformanceResourceTiming after each fetch request', { skip }, (t) => {
16-
t.plan(4)
16+
t.plan(6)
1717
const obs = new PerformanceObserver(list => {
1818
const entries = list.getEntries()
1919
t.equal(entries.length, 1)
@@ -25,6 +25,9 @@ test('should create a PerformanceResourceTiming after each fetch request', { ski
2525
})
2626
t.strictSame(entry.entryType, 'resource')
2727

28+
t.ok(entry.duration >= 0)
29+
t.ok(entry.startTime >= 0)
30+
2831
obs.disconnect()
2932
performance.clearResourceTimings()
3033
})

0 commit comments

Comments
 (0)