refactor(plugins): hide cleanup timeout internals · openclaw/openclaw@6855cbc
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,6 @@ import { loadSessionStore, updateSessionStore } from "../../config/sessions.js";
|
10 | 10 | import { withTempConfig } from "../../gateway/test-temp-config.js"; |
11 | 11 | import { emitAgentEvent, resetAgentEventsForTest } from "../../infra/agent-events.js"; |
12 | 12 | import { resolvePreferredOpenClawTmpDir } from "../../infra/tmp-openclaw-dir.js"; |
13 | | -import { PLUGIN_HOST_CLEANUP_TIMEOUT_MS } from "../host-hook-cleanup-timeout.js"; |
14 | 13 | import { runPluginHostCleanup } from "../host-hook-cleanup.js"; |
15 | 14 | import { |
16 | 15 | clearPluginHostRuntimeState, |
@@ -26,6 +25,8 @@ import { setActivePluginRegistry } from "../runtime.js";
|
26 | 25 | import { createPluginRecord } from "../status.test-helpers.js"; |
27 | 26 | import type { OpenClawPluginApi } from "../types.js"; |
28 | 27 | |
| 28 | +const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000; |
| 29 | + |
29 | 30 | async function waitForPluginEventHandlers(): Promise<void> { |
30 | 31 | await new Promise<void>((resolve) => { |
31 | 32 | setImmediate(resolve); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | /** Verifies host hook cleanup timeout behavior and cancellation reporting. */ |
2 | 2 | import { afterEach, describe, expect, it, vi } from "vitest"; |
3 | | -import { |
4 | | -PLUGIN_HOST_CLEANUP_TIMEOUT_MS, |
5 | | -withPluginHostCleanupTimeout, |
6 | | -} from "./host-hook-cleanup-timeout.js"; |
| 3 | +import { withPluginHostCleanupTimeout } from "./host-hook-cleanup-timeout.js"; |
| 4 | + |
| 5 | +const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000; |
7 | 6 | |
8 | 7 | function requireSetTimeoutCall(callIndex: number): unknown[] { |
9 | 8 | const call = vi.mocked(globalThis.setTimeout).mock.calls[callIndex]; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | /** Max time allowed for plugin host cleanup hooks before failing shutdown. */ |
2 | | -export const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000; |
| 2 | +const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000; |
3 | 3 | |
4 | 4 | /** Error raised when a plugin host cleanup hook exceeds the shutdown timeout. */ |
5 | | -export class PluginHostCleanupTimeoutError extends Error { |
| 5 | +class PluginHostCleanupTimeoutError extends Error { |
6 | 6 | constructor(hookId: string) { |
7 | 7 | super(`plugin host cleanup timed out: ${hookId}`); |
8 | 8 | this.name = "PluginHostCleanupTimeoutError"; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。