mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-10 11:22:58 +00:00
fix(codex): bound native hook cleanup grace
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import type { NativeHookRelayRegistrationHandle } from "openclaw/plugin-sdk/agent-harness-runtime";
|
||||
import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildCodexNativeHookRelayConfig,
|
||||
buildCodexNativeHookRelayDisabledConfig,
|
||||
resolveCodexNativeHookRelayUnregisterGraceMs,
|
||||
} from "./native-hook-relay.js";
|
||||
|
||||
describe("Codex native hook relay config", () => {
|
||||
@@ -251,6 +253,12 @@ describe("Codex native hook relay config", () => {
|
||||
"hooks.Stop": [],
|
||||
});
|
||||
});
|
||||
|
||||
it("caps oversized native hook cleanup grace before scheduling", () => {
|
||||
expect(resolveCodexNativeHookRelayUnregisterGraceMs(Number.MAX_SAFE_INTEGER)).toBe(
|
||||
MAX_TIMER_TIMEOUT_MS,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function createRelay(options?: {
|
||||
|
||||
@@ -5,6 +5,10 @@ import {
|
||||
type NativeHookRelayEvent,
|
||||
type NativeHookRelayRegistrationHandle,
|
||||
} from "openclaw/plugin-sdk/agent-harness-runtime";
|
||||
import {
|
||||
addTimerTimeoutGraceMs,
|
||||
finiteSecondsToTimerSafeMilliseconds,
|
||||
} from "openclaw/plugin-sdk/number-runtime";
|
||||
import type { CodexAppServerRuntimeOptions } from "./config.js";
|
||||
import type { JsonObject, JsonValue } from "./protocol.js";
|
||||
|
||||
@@ -61,11 +65,11 @@ export function resolveCodexNativeHookRelayUnregisterGraceMs(
|
||||
): number {
|
||||
const hookTimeoutMs =
|
||||
typeof hookTimeoutSec === "number" && Number.isFinite(hookTimeoutSec) && hookTimeoutSec > 0
|
||||
? Math.ceil(hookTimeoutSec) * 1000
|
||||
? (finiteSecondsToTimerSafeMilliseconds(Math.ceil(hookTimeoutSec)) ?? 0)
|
||||
: 0;
|
||||
return Math.max(
|
||||
CODEX_NATIVE_HOOK_RELAY_UNREGISTER_GRACE_MS,
|
||||
hookTimeoutMs + CODEX_NATIVE_HOOK_RELAY_UNREGISTER_EXTRA_GRACE_MS,
|
||||
addTimerTimeoutGraceMs(hookTimeoutMs, CODEX_NATIVE_HOOK_RELAY_UNREGISTER_EXTRA_GRACE_MS) ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user