Refactor hook timeout settings to use centralized constants

- Introduced a new module `hook-constants.ts` to define timeout constants for various hooks.
- Updated `cleanup-hook.ts`, `context-hook.ts`, `save-hook.ts`, and `summary-hook.ts` to utilize the new `HOOK_TIMEOUTS.DEFAULT` for fetch timeouts instead of hardcoded values.
- Adjusted worker utility timeouts in `worker-utils.ts` to use constants from `hook-constants.ts`, improving maintainability and consistency across the codebase.
This commit is contained in:
Alex Newman
2025-12-09 14:25:53 -05:00
parent e09e64ade5
commit 1fb8df42b6
14 changed files with 128 additions and 110 deletions
+2 -1
View File
@@ -9,6 +9,7 @@
import path from "path";
import { stdin } from "process";
import { ensureWorkerRunning, getWorkerPort } from "../shared/worker-utils.js";
import { HOOK_TIMEOUTS } from "../shared/hook-constants.js";
export interface SessionStartInput {
session_id?: string;
@@ -30,7 +31,7 @@ async function contextHook(input?: SessionStartInput): Promise<string> {
const url = `http://127.0.0.1:${port}/api/context/inject?project=${encodeURIComponent(project)}`;
try {
const response = await fetch(url, { signal: AbortSignal.timeout(5000) });
const response = await fetch(url, { signal: AbortSignal.timeout(HOOK_TIMEOUTS.DEFAULT) });
if (!response.ok) {
const errorText = await response.text();