Skip to content

Commit

Permalink
Dev tracing: include page visibility when reporting HMR (#55247)
Browse files Browse the repository at this point in the history
Since browsers throttle JavaScript execution when pages (tabs) aren't visible, this can impact the accuracy of this metric.

Test Plan: Tested with page visible and not, and verified the request body reflected this.


Closes WEB-1536
  • Loading branch information
wbinnssmith authored Sep 14, 2023
1 parent 055b5df commit 423d66b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/next/src/client/dev/error-overlay/hot-dev-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ function onFastRefresh(updatedModules: string[]) {
endTime: endLatency,
page: window.location.pathname,
updatedModules,
// Whether the page (tab) was hidden at the time the event occurred.
// This can impact the accuracy of the event's timing.
isPageHidden: document.visibilityState === 'hidden',
})
)
if (self.__NEXT_HMR_LATENCY_CB) {
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/dev/hot-reloader-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export default class HotReloader implements NextJsHotReloaderInterface {
m.replace(/^\.\//, '[project]/')
),
page: payload.page,
isPageHidden: payload.isPageHidden,
},
}
break
Expand Down

0 comments on commit 423d66b

Please sign in to comment.