()
| 422 | } |
| 423 | |
| 424 | const dispose = async () => { |
| 425 | if (done) return |
| 426 | done = true |
| 427 | ctrl.abort() |
| 428 | const queue = [...list].reverse() |
| 429 | list = [] |
| 430 | const until = Date.now() + disposeTimeoutMs |
| 431 | for (const item of queue) { |
| 432 | const left = until - Date.now() |
| 433 | if (left <= 0) { |
| 434 | fail("timed out cleaning up tui plugin", { |
| 435 | path: load.spec, |
| 436 | id, |
| 437 | timeout: disposeTimeoutMs, |
| 438 | }) |
| 439 | break |
| 440 | } |
| 441 | |
| 442 | const out = await runCleanup(item.fn, left) |
| 443 | if (out.type === "ok") continue |
| 444 | if (out.type === "timeout") { |
| 445 | fail("timed out cleaning up tui plugin", { |
| 446 | path: load.spec, |
| 447 | id, |
| 448 | timeout: disposeTimeoutMs, |
| 449 | }) |
| 450 | break |
| 451 | } |
| 452 | |
| 453 | if (out.type === "error") { |
| 454 | fail("failed to clean up tui plugin", { |
| 455 | path: load.spec, |
| 456 | id, |
| 457 | error: out.error, |
| 458 | }) |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | return { |
| 464 | lifecycle, |
nothing calls this directly
no test coverage detected