mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
refactor(plugins): hide cleanup timeout internals
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user