Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/tools/HttpRequestTool/HttpRequestTool.test.ts
Binary file not shown.
Binary file added src/tools/HttpRequestTool/HttpRequestTool.ts
Binary file not shown.
Binary file added src/tools/HttpRequestTool/prompt.ts
Binary file not shown.
22 changes: 22 additions & 0 deletions src/utils/cleanupRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,25 @@ export function registerCleanup(cleanupFn: () => Promise<void>): () => void {
export async function runCleanupFunctions(): Promise<void> {
await Promise.all(Array.from(cleanupFunctions).map(fn => fn()))
}

// --- Cleanup-safe timer and AbortController helpers ---

export function setCleanupTimeout(fn: (...args: any[]) => void, ms: number): { id: ReturnType<typeof setTimeout>; unregister: () => void } {
const id = setTimeout(fn, ms)
const unregister = registerCleanup(() => clearTimeout(id))
return { id, unregister }
}

export function setCleanupInterval(fn: (...args: any[]) => void, ms: number): ReturnType<typeof setInterval> {
const id = setInterval(fn, ms)
registerCleanup(() => clearInterval(id))
return id
}

export function createCleanupAbortController(): AbortController {
const controller = new AbortController()
registerCleanup(() => {
try { controller.abort() } catch {}
})
return controller
}