supermemory icon indicating copy to clipboard operation
supermemory copied to clipboard

`forgetMemoryRequest` drops its 30s timeout whenever a caller passes a signal

Open rajarshidattapy opened this issue 3 months ago • 2 comments

Severity: Low (latent — defeats the fix from #1451) File: packages/tools/src/shared/forget-memory.ts:35

Description

#1451 ("fix(tools): bound memory forget requests") added a 30-second abort so a hung DELETE /v4/memories can't wedge the tool call. The two signals are combined with ??, so they're mutually exclusive:

signal: options?.signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS),

Pass a cancellation signal and the request becomes unbounded again — exactly the condition the commit set out to remove. A caller who wants both cancellation and a timeout has no way to express it through this API.

No production call site passes options today (ai-sdk.ts:332 and openai/tools.ts:490 both omit it), so this is latent rather than live. It becomes a real hang the first time someone wires up cancellation.

Suggested fix

Compose the two instead of choosing between them:

signal: options?.signal
    ? AbortSignal.any([options.signal, AbortSignal.timeout(FETCH_TIMEOUT_MS)])
    : AbortSignal.timeout(FETCH_TIMEOUT_MS),

AbortSignal.any is available in Node 20+ (the repo's engines floor), Bun, and workerd. packages/tools/src/tool-operations.test.ts already exercises the signal path, so a case asserting the timeout still fires with a caller signal present is a one-line addition.

rajarshidattapy avatar Aug 19 '26 06:08 rajarshidattapy

ENG-1207

linear-code[bot] avatar Aug 19 '26 06:08 linear-code[bot]

Opened #1675 composing caller signals with AbortSignal.timeout via AbortSignal.any (also fixed the same pattern in MCP client's getDocuments).

Adityakk9031 avatar Sep 17 '26 11:09 Adityakk9031