You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(tools, mcp): compose caller abort signal with fetch timeout (#1549) - #1675
When a caller passed a custom signal (e.g. for user cancellation), this completely discarded the 30-second abort timeout, leaving the HTTP request unbounded if the server hung or stalled.
Solution
Composed caller cancellation signals with AbortSignal.timeout(FETCH_TIMEOUT_MS) via AbortSignal.any([options.signal, AbortSignal.timeout(FETCH_TIMEOUT_MS)]):
If the caller aborts, the request aborts immediately.
If the endpoint hangs, the request still times out after 30 seconds.
Applied to both forgetMemoryRequest and MCP client's getDocuments.
Updated unit test in packages/tools/src/tool-operations.test.ts to assert composed signal abort behavior.
I checked this PR and #1595, which fix the same bug (#1549).
The fix is correct, but the changed test does not catch the bug. I ran the test from this PR against the main version of forget-memory.ts (npx vitest run src/tool-operations.test.ts in packages/tools), and it passes. It only checks that the caller signal aborts the request, and that worked before the fix. #1595 adds a test that stubs AbortSignal.timeout and fires only the timeout leg. That test fails on main and passes with the fix.
This PR also fixes the same pattern in apps/mcp/src/server/client/index.ts, and #1595 does not. One option: merge #1595 and carry this MCP hunk over to it.
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
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.
Resolves #1549
Summary
In
packages/tools/src/shared/forget-memory.tsandapps/mcp/src/server/client/index.ts,signalwas computed using nullish coalescing:When a caller passed a custom
signal(e.g. for user cancellation), this completely discarded the 30-second abort timeout, leaving the HTTP request unbounded if the server hung or stalled.Solution
Composed caller cancellation signals with
AbortSignal.timeout(FETCH_TIMEOUT_MS)viaAbortSignal.any([options.signal, AbortSignal.timeout(FETCH_TIMEOUT_MS)]):forgetMemoryRequestand MCP client'sgetDocuments.packages/tools/src/tool-operations.test.tsto assert composed signal abort behavior.