MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / queueReload

Function queueReload

packages/node/src/dev/hotStateReload.ts:395–425  ·  view source on GitHub ↗
(phase: "manual" | "watch")

Source from the content-addressed store, hash-verified

393 }
394
395 function queueReload(phase: "manual" | "watch"): Promise<boolean> {
396 const changedPath = pendingChangePath;
397 pendingChangePath = undefined;
398 const op = reloadChain.then(async () => {
399 if (!running) return false;
400 try {
401 const moduleNs = await importLatestModule();
402 if (!running) return false;
403 reloadAdapter.applyReload(moduleNs);
404 log({
405 level: "info",
406 message:
407 phase === "manual"
408 ? `HSR manual ${targetLabel} reload applied`
409 : `HSR file change ${targetLabel} reload applied`,
410 ...(changedPath === undefined ? {} : { changedPath }),
411 });
412 return true;
413 } catch (error: unknown) {
414 emitError(error, { phase: "reload", ...(changedPath ? { changedPath } : {}) });
415 log({
416 level: "error",
417 message: `HSR reload failed; keeping previous ${targetLabel}`,
418 ...(changedPath === undefined ? {} : { changedPath }),
419 });
420 return false;
421 }
422 });
423 reloadChain = op.catch(() => false);
424 return op;
425 }
426
427 function scheduleWatchRefresh(): void {
428 if (!running || refreshTimer !== null) return;

Callers 2

onWatchEventFunction · 0.85
reloadNowFunction · 0.85

Calls 2

importLatestModuleFunction · 0.85
emitErrorFunction · 0.85

Tested by

no test coverage detected