Skip to content

fix(tools): keep the forget timeout when a caller passes a signal - #1565

Open
rajarshidattapy wants to merge 2 commits into
supermemoryai:mainfrom
rajarshidattapy:fix/forget-memory-timeout-with-signal
Open

fix(tools): keep the forget timeout when a caller passes a signal#1565
rajarshidattapy wants to merge 2 commits into
supermemoryai:mainfrom
rajarshidattapy:fix/forget-memory-timeout-with-signal

Conversation

@rajarshidattapy

Copy link
Copy Markdown
Contributor

Fixes #1549

Problem

forgetMemoryRequest picked between the caller's signal and the 30s abort with ??:

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

The two are mutually exclusive that way, so passing a cancellation signal silently drops the timeout and a hung DELETE /v4/memories can wedge the tool call again — the condition #1451 added the timeout to remove. There was also no way for a caller to ask for both.

Latent today: no production call site passes options (ai-sdk.ts:332 and openai/tools.ts:490 both omit it). It becomes a real hang the first time cancellation gets wired up.

Fix

Compose the signals with AbortSignal.any instead of choosing between them, so cancellation and the timeout are both live. Available in Node 20+ (the repo's engines floor), Bun, and workerd.

Test

Updated the existing signal case in packages/tools/src/tool-operations.test.ts to assert the composed behaviour: the signal handed to fetch is no longer the caller's (so the timeout is still attached), and aborting the caller's controller still aborts the request. All 14 tests in the file pass.

Note (not in this PR)

apps/mcp/src/server/client/index.ts:369 (getDocuments) has the identical ?? pattern. No caller there passes options either, so it's the same latent bug in a separate package — left out to keep this diff scoped to the issue; happy to fold it in if you'd prefer one PR.

`forgetMemoryRequest` combined the caller signal and the 30s timeout with
`??`, so passing a cancellation signal made the DELETE unbounded again --
the exact hang supermemoryai#1451 set out to remove. Compose them with
`AbortSignal.any` so cancellation and the timeout both stay live.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant