refactor(plugins): hide cleanup timeout internals

This commit is contained in:
Vincent Koc
2026-06-17 10:45:04 +08:00
parent bfc5e49291
commit 6855cbc3df
3 changed files with 7 additions and 7 deletions
@@ -10,7 +10,6 @@ import { loadSessionStore, updateSessionStore } from "../../config/sessions.js";
import { withTempConfig } from "../../gateway/test-temp-config.js";
import { emitAgentEvent, resetAgentEventsForTest } from "../../infra/agent-events.js";
import { resolvePreferredOpenClawTmpDir } from "../../infra/tmp-openclaw-dir.js";
import { PLUGIN_HOST_CLEANUP_TIMEOUT_MS } from "../host-hook-cleanup-timeout.js";
import { runPluginHostCleanup } from "../host-hook-cleanup.js";
import {
clearPluginHostRuntimeState,
@@ -26,6 +25,8 @@ import { setActivePluginRegistry } from "../runtime.js";
import { createPluginRecord } from "../status.test-helpers.js";
import type { OpenClawPluginApi } from "../types.js";
const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000;
async function waitForPluginEventHandlers(): Promise<void> {
await new Promise<void>((resolve) => {
setImmediate(resolve);
@@ -1,9 +1,8 @@
/** Verifies host hook cleanup timeout behavior and cancellation reporting. */
import { afterEach, describe, expect, it, vi } from "vitest";
import {
PLUGIN_HOST_CLEANUP_TIMEOUT_MS,
withPluginHostCleanupTimeout,
} from "./host-hook-cleanup-timeout.js";
import { withPluginHostCleanupTimeout } from "./host-hook-cleanup-timeout.js";
const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000;
function requireSetTimeoutCall(callIndex: number): unknown[] {
const call = vi.mocked(globalThis.setTimeout).mock.calls[callIndex];
+2 -2
View File
@@ -1,8 +1,8 @@
/** Max time allowed for plugin host cleanup hooks before failing shutdown. */
export const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000;
const PLUGIN_HOST_CLEANUP_TIMEOUT_MS = 5_000;
/** Error raised when a plugin host cleanup hook exceeds the shutdown timeout. */
export class PluginHostCleanupTimeoutError extends Error {
class PluginHostCleanupTimeoutError extends Error {
constructor(hookId: string) {
super(`plugin host cleanup timed out: ${hookId}`);
this.name = "PluginHostCleanupTimeoutError";