fix(tools): keep the forget timeout when a caller passes a signal - #1565
Open
rajarshidattapy wants to merge 2 commits into
Open
fix(tools): keep the forget timeout when a caller passes a signal#1565rajarshidattapy wants to merge 2 commits into
rajarshidattapy wants to merge 2 commits into
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1549
Problem
forgetMemoryRequestpicked between the caller's signal and the 30s abort with??:The two are mutually exclusive that way, so passing a cancellation signal silently drops the timeout and a hung
DELETE /v4/memoriescan 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:332andopenai/tools.ts:490both omit it). It becomes a real hang the first time cancellation gets wired up.Fix
Compose the signals with
AbortSignal.anyinstead of choosing between them, so cancellation and the timeout are both live. Available in Node 20+ (the repo'senginesfloor), Bun, and workerd.Test
Updated the existing signal case in
packages/tools/src/tool-operations.test.tsto assert the composed behaviour: the signal handed tofetchis 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 passesoptionseither, 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.