fix patch bridge feat/phase-2g-bundle #92 / 100
AI Agent git-import/068377df · 85 days ago · May 1, 2026 · Diff

fix(bridge): per-step index timing logs; raise Netlify function timeouts 26→60s

POST /api/v1/index has been timing out at the Netlify sync-function wall after the EMBEDDING_PROVIDER flip from openai → deepinfra (BAAI/bge-large-en-v1.5, 1024 dim). Gateway logs show ~30.4s durations followed by UI 504+HTML body; bridge logs in the same window show no single long invocation, so we cannot yet tell whether the bottleneck is the embed loop, the canister export, the sqlite-vec persist to Netlify Blobs, or gateway-side billing-store writes.

This change does two narrow things and intentionally no behavior fix yet:

1. New pure module hub/bridge/index-timing.mjs with createIndexTimer({...}). Wired into POST /api/v1/index in hub/bridge/server.mjs to emit one JSON line per sub-step under a stable type (knowtation_index_step) plus a final knowtation_index_done line on every exit path (success, early return on empty vault, all error returns, catch). Per-batch embed lines include embed_ms, batch_size, tokens_in_batch; embed_total summarizes provider, model, batches, min/avg/max batch ms. Logger and clock are injected so the module is unit-testable without booting Express, the bridge, the canister, or the embedding provider.

2. Bumps [functions."gateway"] (netlify.toml) and [functions."bridge"] (deploy/bridge/netlify.toml) timeout from 26 → 60. 60 s is the current Netlify sync-function platform max per docs.netlify.com/build/functions/overview. This buys headroom but is not a fix on its own — the timing logs above will tell us whether the next branch should parallelize the embed loop (option B) or move indexing to a Background Function (option C).

Tests: - test/bridge-index-timing.test.mjs covers stable type/shape, elapsed-ms math, idempotent finish (post-finish step is a no-op), empty-name rejection so we never emit untyped lines, default console.log/Date.now smoke, and null vault/uid serialization for early-error paths. - Full repo: 1728/1728 pass, 1 skipped, 0 fail.

After deploy, re-index once and grep bridge logs for type:knowtation_index_step + type:knowtation_index_done to identify the dominant sub-step before opening the next branch.

sha256:0f870195e38dbe6dd6d24a20de064f1ab7c27f1dab583d8436e5295ee0e6dae4 sha
sha256:53666657353841d031a389fec3df58d2cc0a5bd981e98880193b58d5611bc191 snapshot

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:0f870195e38dbe6dd6d24a20de064f1ab7c27f1dab583d8436e5295ee0e6dae4 --body "your comment"