Unverified Commit 493e3eaf authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Start the version info request explicitly instead of in a getter

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 231a942a
...@@ -1493,28 +1493,26 @@ export async function createHotReloaderTurbopack( ...@@ -1493,28 +1493,26 @@ export async function createHotReloaderTurbopack(
// This fetch is not kicked off eagerly because the first `fetch()` in // This fetch is not kicked off eagerly because the first `fetch()` in
// Node.js adds roughly 20ms main-thread blocking to load the SSL certificate cache // Node.js adds roughly 20ms main-thread blocking to load the SSL certificate cache
// We don't want that blocking time to be in the hot path for the `ready in` logging. // We don't want that blocking time to be in the hot path for the `ready in` logging.
// Instead, the fetch is kicked off lazily when `getCurrentVersionInfo()` is first called. // Instead, `startVersionInfoRequest()` kicks it off lazily when the first HMR
// The registry request is never awaited: until it resolves, clients get a // client connects. The registry request is never awaited: until it resolves,
// placeholder in `sync`, and every connected client receives the resolved // clients get a placeholder in `sync`, and every connected client receives
// info in a `versionInfo` message. Otherwise a slow registry would delay // the resolved info in a `versionInfo` message. Otherwise a slow registry
// `sync`, and with it the whole dev overlay. // would delay `sync`, and with it the whole dev overlay.
const getCurrentVersionInfo = (): VersionInfo => { const startVersionInfoRequest = () => {
if (!versionInfoRequested) { if (versionInfoRequested) return
versionInfoRequested = true versionInfoRequested = true
void getVersionInfo().then((versionInfo) => { void getVersionInfo().then((versionInfo) => {
resolvedVersionInfo = versionInfo resolvedVersionInfo = versionInfo
for (const client of [ for (const client of [
...clientsWithoutHtmlRequestId, ...clientsWithoutHtmlRequestId,
...clientsByHtmlRequestId.values(), ...clientsByHtmlRequestId.values(),
]) { ]) {
sendToClient(client, { sendToClient(client, {
type: HMR_MESSAGE_SENT_TO_BROWSER.VERSION_INFO, type: HMR_MESSAGE_SENT_TO_BROWSER.VERSION_INFO,
versionInfo, versionInfo,
}) })
} }
}) })
}
return resolvedVersionInfo ?? getPendingVersionInfo()
} }
let devtoolsFrontendUrl: string | undefined let devtoolsFrontendUrl: string | undefined
...@@ -1829,6 +1827,8 @@ export async function createHotReloaderTurbopack( ...@@ -1829,6 +1827,8 @@ export async function createHotReloaderTurbopack(
} }
sendToClient(client, turbopackConnectedMessage) sendToClient(client, turbopackConnectedMessage)
startVersionInfoRequest()
if (devIndicatorServerState.disabledUntil < Date.now()) { if (devIndicatorServerState.disabledUntil < Date.now()) {
devIndicatorServerState.disabledUntil = 0 devIndicatorServerState.disabledUntil = 0
} }
...@@ -1858,7 +1858,7 @@ export async function createHotReloaderTurbopack( ...@@ -1858,7 +1858,7 @@ export async function createHotReloaderTurbopack(
errors, errors,
warnings: [], warnings: [],
hash: '', hash: '',
versionInfo: getCurrentVersionInfo(), versionInfo: resolvedVersionInfo ?? getPendingVersionInfo(),
hasVulnerabilityInsight, hasVulnerabilityInsight,
debug: { debug: {
devtoolsFrontendUrl, devtoolsFrontendUrl,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment