Skip to content

Commit

Permalink
Add check for startLatency in fast refresh (#26417)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens authored Jun 21, 2021
1 parent 075139a commit 4d13d67
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/next/client/dev/error-overlay/hot-dev-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,20 @@ function handleErrors(errors) {
}
}

let startLatency = undefined

function onFastRefresh(hasUpdates) {
DevOverlay.onBuildOk()
if (hasUpdates) {
DevOverlay.onRefresh()
}

const latency = Date.now() - startLatency
console.log(`[Fast Refresh] done in ${latency}ms`)
if (self.__NEXT_HMR_LATENCY_CB) {
self.__NEXT_HMR_LATENCY_CB(latency)
if (startLatency) {
const latency = Date.now() - startLatency
console.log(`[Fast Refresh] done in ${latency}ms`)
if (self.__NEXT_HMR_LATENCY_CB) {
self.__NEXT_HMR_LATENCY_CB(latency)
}
}
}

Expand All @@ -192,8 +196,6 @@ function handleAvailableHash(hash) {
mostRecentCompilationHash = hash
}

let startLatency = undefined

// Handle messages from the server.
function processMessage(e) {
const obj = JSON.parse(e.data)
Expand Down

0 comments on commit 4d13d67

Please sign in to comment.