diff --git a/packages/next/client/dev/error-overlay/hot-dev-client.js b/packages/next/client/dev/error-overlay/hot-dev-client.js index 602c92e51b21d..afc67f15879eb 100644 --- a/packages/next/client/dev/error-overlay/hot-dev-client.js +++ b/packages/next/client/dev/error-overlay/hot-dev-client.js @@ -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) + } } } @@ -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)