Skip to content

Commit

Permalink
fix: correctly calculate resource timing duration (nodejs#1988)
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack authored and crysmags committed Feb 27, 2024
1 parent b39cce9 commit b7ea0c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
// capability.
// TODO: given global’s relevant settings object’s cross-origin isolated
// capability?
response.timingInfo.endTime = coarsenedSharedCurrentTime()
timingInfo.endTime = coarsenedSharedCurrentTime()

// 10. Set response’s timing info to timingInfo.
response.timingInfo = timingInfo
Expand Down
5 changes: 4 additions & 1 deletion test/fetch/resource-timing.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
const skip = nodeMajor < 18 || (nodeMajor === 18 && nodeMinor < 2)

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

t.ok(entry.duration >= 0)
t.ok(entry.startTime >= 0)

obs.disconnect()
performance.clearResourceTimings()
})
Expand Down

0 comments on commit b7ea0c5

Please sign in to comment.