(phase: "manual" | "watch")
| 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; |
no test coverage detected