Skip to content

Commit 4d13d67

Browse files
authored
Add check for startLatency in fast refresh (#26417)
1 parent 075139a commit 4d13d67

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/next/client/dev/error-overlay/hot-dev-client.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,20 @@ function handleErrors(errors) {
173173
}
174174
}
175175

176+
let startLatency = undefined
177+
176178
function onFastRefresh(hasUpdates) {
177179
DevOverlay.onBuildOk()
178180
if (hasUpdates) {
179181
DevOverlay.onRefresh()
180182
}
181183

182-
const latency = Date.now() - startLatency
183-
console.log(`[Fast Refresh] done in ${latency}ms`)
184-
if (self.__NEXT_HMR_LATENCY_CB) {
185-
self.__NEXT_HMR_LATENCY_CB(latency)
184+
if (startLatency) {
185+
const latency = Date.now() - startLatency
186+
console.log(`[Fast Refresh] done in ${latency}ms`)
187+
if (self.__NEXT_HMR_LATENCY_CB) {
188+
self.__NEXT_HMR_LATENCY_CB(latency)
189+
}
186190
}
187191
}
188192

@@ -192,8 +196,6 @@ function handleAvailableHash(hash) {
192196
mostRecentCompilationHash = hash
193197
}
194198

195-
let startLatency = undefined
196-
197199
// Handle messages from the server.
198200
function processMessage(e) {
199201
const obj = JSON.parse(e.data)

0 commit comments

Comments
 (0)