Cached-vector attach starves MCP initialize; OpenCode marks memorix failed
Description
After HTTP is up and /health is green, attachCachedVectors updates tens of thousands of Orama documents with 1024-d vectors on the same event loop. Yields every 10/50 updates are not enough: the process sits at 60–70% CPU for many minutes.
MCP initialize then accepts the TCP connection but writes 0 bytes for 20s. OpenCode mcp list reports:
✗ mcpm_memorix failed
http://127.0.0.1:3211/mcp
even though the config is correct and /health returns ok.
Steps to Reproduce
- Start
serve-httpon a 40k+ store with a warm JSONL cache. - Trigger runtime init (
memorix_session_startor any non-bootstrap tool). - While CPU is high, POST MCP
initializewith a 15–20s timeout, or runopencode mcp list.
Expected Behavior
initialize stays ~50–200ms during vector attach. OpenCode shows mcpm_memorix connected. Attach continues in the background.
Actual Behavior
curl /mcp initialize timed out at 20s with 0 bytes while /health still succeeded. After attach finished, initialize worked. OpenCode had already marked the server failed.
Environment
- Memorix 1.6.0
- MacBook 13, ~52k observations, 27,320 cached vectors
- OpenCode remote MCP
http://127.0.0.1:3211/mcp
Additional Context
#214 now setImmediates every attach and setTimeout(10) every 25 updates. After that change: initialize during attach was 0.043s, and OpenCode showed ✓ mcpm_memorix connected.
Related: HTTP wedge issue, #214.
Fix is in PR https://github.com/AVIDS2/memorix/pull/214 — not on main yet, so leaving this issue open until that PR merges.
Relevant work:
01763fa1ee— Orama cached-vector attach yields so MCP initialize stays ~50ms instead of starving the event loop- Files:
src/store/orama-store.ts,src/embedding/api-provider.ts
Fixed by #214 and released in v1.6.2. Cached-vector attachment moved off the MCP initialize critical path; OpenCode can complete initialization while recovery continues in the background. Closing as shipped.