Skip to content

fix: enforce MCP execution bounds - #255

Closed
lzehrung wants to merge 4 commits into
fix/mcp-session-safety-basefrom
fix/mcp-bounds-and-regressions
Closed

fix: enforce MCP execution bounds#255
lzehrung wants to merge 4 commits into
fix/mcp-session-safety-basefrom
fix/mcp-bounds-and-regressions

Conversation

@lzehrung

Copy link
Copy Markdown
Owner

Summary

  • Release initialization reservations on every rejected HTTP initialization path.
  • Preserve healthy sessions across request-scoped transport validation failures.
  • Enforce worker-backed SQLite deadlines and document the in-process fallback limit.

Verification

  • Focused MCP and SQLite suites passed, including capacity, session-survival, deadline, and fallback-contract regressions.

codegraph and others added 4 commits August 15, 2026 12:17
Three post-review defects in the MCP HTTP transport and raw SQLite query path:

1. Legacy initialize capacity reservations leaked whenever the SDK transport
   answered a pre-session 4xx without throwing (most notably Accept header
   validation): onsessioninitialized never fired to release it, and the
   catch block only covered thrown errors. Release the reservation whenever
   handleLegacyMcpSessionRequest resolves without a session having been
   initialized.

2. transport.onerror deleted the whole legacy session for any per-request
   SDK validation error (bad Accept, wrong Content-Type, malformed JSON,
   unsupported protocol version, ...), even though those already answered
   their own request and left the transport healthy. Session teardown is
   now driven by onclose alone; onerror only logs.

3. The in-process SQLite query fallback (used when the compiled worker
   asset can't be located) only checks its deadline between already-produced
   rows, so a statement slow to produce its first row isn't bounded by it.
   node:sqlite has no interrupt API, so true enforcement requires the worker
   thread this fallback exists because it couldn't find; corrected the
   public contract instead (JSDoc, docs/library-api.md, and a one-time
   degraded-mode log) so the gap is documented and observable rather than
   silently implied away.
@lzehrung

Copy link
Copy Markdown
Owner Author

Superseded by #264, which consolidates the MCP session, transport, SQLite, and streaming fixes.

@lzehrung lzehrung closed this Aug 16, 2026
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.

1 participant