MCPcopy
hub / github.com/vitejs/vite / queueUpdate

Method queueUpdate

packages/vite/src/shared/hmr.ts:252–262  ·  view source on GitHub ↗

* buffer multiple hot updates triggered by the same src change * so that they are invoked in the same order they were sent. * (otherwise the order may be inconsistent because of the http request round trip)

(payload: Update)

Source from the content-addressed store, hash-verified

250 * (otherwise the order may be inconsistent because of the http request round trip)
251 */
252 public async queueUpdate(payload: Update): Promise<void> {
253 this.updateQueue.push(this.fetchUpdate(payload))
254 if (!this.pendingUpdateQueue) {
255 this.pendingUpdateQueue = true
256 await Promise.resolve()
257 this.pendingUpdateQueue = false
258 const loading = [...this.updateQueue]
259 this.updateQueue = []
260 ;(await Promise.all(loading)).forEach((fn) => fn && fn())
261 }
262 }
263
264 private async fetchUpdate(update: Update): Promise<(() => void) | undefined> {
265 const { path, acceptedPath, firstInvalidatedBy } = update

Callers 2

handleMessageFunction · 0.80

Calls 3

fetchUpdateMethod · 0.95
resolveMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected