Skip to content

fix(tools, mcp): compose caller abort signal with fetch timeout (#1549) - #1675

Closed
Adityakk9031 wants to merge 2 commits into
supermemoryai:mainfrom
Adityakk9031:fix/bounded-forget-memory-timeout-1549
Closed

Adityakk9031 wants to merge 2 commits into
supermemoryai:mainfrom
Adityakk9031:fix/bounded-forget-memory-timeout-1549

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Resolves #1549

Summary

In packages/tools/src/shared/forget-memory.ts and apps/mcp/src/server/client/index.ts, signal was computed using nullish coalescing:

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

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.

@phant0um

Copy link
Copy Markdown

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.

@MaheshtheDev

Copy link
Copy Markdown
Member

🤖 AI-assisted triage, reviewed by @MaheshtheDev.

Thanks! #1595 got to #1549 first and also covers the MCP client. Closing.

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

3 participants