fix(tools): keep the forget-request timeout when a caller passes a signal - #1603
Open
Cintu07 wants to merge 1 commit into
Open
fix(tools): keep the forget-request timeout when a caller passes a signal#1603Cintu07 wants to merge 1 commit into
Cintu07 wants to merge 1 commit into
Conversation
…gnal forgetMemoryRequest combined the caller signal and the 30s timeout with `??`, so passing a cancellation signal dropped the timeout and made the DELETE /v4/memories request unbounded again, undoing supermemoryai#1451. compose them with AbortSignal.any so both still apply. updates the existing signal test to assert the composed behavior. closes supermemoryai#1549
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.
what breaks
forgetMemoryRequest(packages/tools/src/shared/forget-memory.ts) combined the caller's abort signal and the 30s fetch timeout with??:so the two are mutually exclusive. Pass a cancellation signal and the request loses its timeout and becomes unbounded again, which reopens the hang #1451 set out to close. A caller that wants both cancellation and a timeout has no way to ask for it.
why it matters
It is latent today, because no production call site passes
options(ai-sdk.ts:332andopenai/tools.ts:490both omit it). It becomes a real hang the first time someone wires up cancellation.the fix
Compose the two with
AbortSignal.anyinstead of choosing between them, so the request aborts on whichever fires first:AbortSignal.anyis available on the repo's Node 20enginesfloor, Bun, and workerd.verified
Updated the existing signal test in
tool-operations.test.tsto assert the composed behavior: a composite signal (not the raw caller signal) that still aborts when the caller aborts. Full file is green:Closes #1549