waitForSuccessfulPingInternal() — vite Function Reference
Architecture documentation for the waitForSuccessfulPingInternal() function in client.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD f5953798_0aef_33e3_5df8_38291253d4f3["waitForSuccessfulPingInternal()"] 85908ff5_4d12_826d_8235_531f91538758["client.ts"] f5953798_0aef_33e3_5df8_38291253d4f3 -->|defined in| 85908ff5_4d12_826d_8235_531f91538758 62c89f60_860f_098a_c8e3_9d5d77bd220d["waitForSuccessfulPing()"] 62c89f60_860f_098a_c8e3_9d5d77bd220d -->|calls| f5953798_0aef_33e3_5df8_38291253d4f3 cd667263_6006_f2fa_4fbd_b90378665c4d["pingWorkerContentMain()"] cd667263_6006_f2fa_4fbd_b90378665c4d -->|calls| f5953798_0aef_33e3_5df8_38291253d4f3 2752be78_665c_da23_b678_4ae249d7fa39["close()"] f5953798_0aef_33e3_5df8_38291253d4f3 -->|calls| 2752be78_665c_da23_b678_4ae249d7fa39 style f5953798_0aef_33e3_5df8_38291253d4f3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/client/client.ts lines 461–522
async function waitForSuccessfulPingInternal(
socketUrl: string,
visibilityManager: VisibilityManager,
ms = 1000,
) {
function wait(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
async function ping() {
try {
const socket = new WebSocket(socketUrl, 'vite-ping')
return new Promise<boolean>((resolve) => {
function onOpen() {
resolve(true)
close()
}
function onError() {
resolve(false)
close()
}
function close() {
socket.removeEventListener('open', onOpen)
socket.removeEventListener('error', onError)
socket.close()
}
socket.addEventListener('open', onOpen)
socket.addEventListener('error', onError)
})
} catch {
return false
}
}
function waitForWindowShow(visibilityManager: VisibilityManager) {
return new Promise<void>((resolve) => {
const onChange = (newVisibility: DocumentVisibilityState) => {
if (newVisibility === 'visible') {
resolve()
visibilityManager.listeners.delete(onChange)
}
}
visibilityManager.listeners.add(onChange)
})
}
if (await ping()) {
return
}
await wait(ms)
while (true) {
if (visibilityManager.currentState === 'visible') {
if (await ping()) {
break
}
await wait(ms)
} else {
await waitForWindowShow(visibilityManager)
}
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does waitForSuccessfulPingInternal() do?
waitForSuccessfulPingInternal() is a function in the vite codebase, defined in packages/vite/src/client/client.ts.
Where is waitForSuccessfulPingInternal() defined?
waitForSuccessfulPingInternal() is defined in packages/vite/src/client/client.ts at line 461.
What does waitForSuccessfulPingInternal() call?
waitForSuccessfulPingInternal() calls 1 function(s): close.
What calls waitForSuccessfulPingInternal()?
waitForSuccessfulPingInternal() is called by 2 function(s): pingWorkerContentMain, waitForSuccessfulPing.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free