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
Graph enumeration budget cannot interrupt a synchronous state::list #113
LIVE_ENUMERATION_BUDGET_MS (src/functions/graph.ts:59) is meant to put a 6000 ms limit on enumerating the graph. In practice it limits nothing.
The race:mem::graph-snapshot-rebuild (graph.ts:1456) wraps Promise.all([kv.list(graphNodes), kv.list(graphEdges)]) in withTimeout(…, LIVE_ENUMERATION_BUDGET_MS).
Why the timer cannot fire: under the in-process Engine, state::list calls SqliteState.list (src/engine/inproc/state.ts:272). That runs a synchronous .all() and then JSON.parses every row before it returns, and the event loop is blocked for the whole call. The timer only gets a turn at cooperate()'s setImmediate, which comes after a listing has already finished.
Consequences:
On a large graph the enumeration takes as long as it takes, however the budget is set.
If the first listing alone runs past 6 s, the race can reject between the two listings. The work still continues, so the caller sees a timeout for work that was not stopped.
Stale rationale: the budget dates from the iii engine, where state::list was an async RPC and racing it made sense (ADR 0001).
Misleading comment: the comment above the constant (graph.ts:56) says "the query handler races the enumeration". The only use is in snapshot rebuild, not the query handler.
What a fix decides
Either:
bound the work itself, for example by counting rows (SELECT count(*)) or paging the scope before loading it, so an oversized graph is refused before the event loop blocks; or
delete the timer and rely on the existing REBUILD_SAFE_NODE_CEILING check, moved ahead of the full load.
In both cases, correct the comment at graph.ts:56.
Activity