Repository navigation
Description
Problem
nodespace diagnostics reports Total nodes: 0 against a database holding 31,473 nodes:
Database size: 95.33 MB
Total nodes: 0
Root nodes: 399
...
Errors:
- QueryNodesSimple failed: status: OutOfRange, message: "Error, decoded message
length too large: found 9231573 bytes, the limit is: 4194304 bytes"
The call pulls every node to compute a count, producing a ~9.2MB message that exceeds tonic's default 4MB ceiling. The transport error is captured in an errors list, but the count independently falls back to 0 — so the headline number is confidently wrong while the real cause sits further down the output.
Note Root nodes: 399 is correct, which makes the 0 more misleading, not less: the report looks partially healthy.
Three distinct defects
1. A transport failure renders as a plausible number
packages/cli/src/commands/diagnostics.rs:151-168 — on Err, the node list falls back to Vec::new(), and total_node_count = all_nodes.len() (:180) then yields 0. A failed measurement is indistinguishable from a genuinely empty database.
Same pattern at :113 (databases list) and :166.
This is the most important fix and the cheapest. A count that could not be measured must render as unavailable / —, never 0. It applies wherever this fallback shape appears, independent of any limit decision.
2. Row-count limits do not bound bytes
The call is already guarded: QUERY_LIMIT = 100_000 (diagnostics.rs:29) plus a truncation warning when a full batch comes back (:170-177). Thoughtful, and ineffective here — 31,473 rows is far under the 100k row cap but ~9.2MB over the 4MB byte cap. The guard never runs, because the failure happens at the transport before the check.
A limit expressed in rows cannot protect a ceiling expressed in bytes while row size is unbounded.
Fix: stop transferring data to count it. Diagnostics wants an integer; COUNT(*) returns 8 bytes instead of every node's full content. This removes the failure entirely for the case actually hit, rather than making it less likely.
Note recent_node_ids (:196) also sorts the full in-memory snapshot because QueryNodesSimple exposes no ORDER BY — worth a bounded ORDER BY created_at DESC LIMIT n on the same pass rather than pulling everything to sort client-side.
3. The limit is unconfigured, and other payloads are genuinely unbounded
No max_decoding_message_size / max_encoding_message_size appears anywhere in the codebase, so every gRPC call runs on tonic's 4MB default — a value nobody chose for this workload.
This is not confined to diagnostics. get_children_tree (packages/daemon/src/services/node_service.rs:363-376) serialises an entire subtree into a single tree_json string with no size bound. That is on the application's hot path: a sufficiently large document would fail to open, not merely fail to be diagnosed.
Decide deliberately rather than by default. Options, roughly in order of preference:
- Bound the payload (paginate or stream
get_children_tree) - Set an explicit configured limit, chosen for the workload, so the ceiling is a decision rather than a library default
- Raising the limit alone only moves the cliff — it needs a stated maximum document size to be meaningful
Explicitly not proposing a blanket limit increase as the primary fix: the 9.2MB payload was a bad implementation, not a real requirement, and raising the ceiling would have hidden this rather than surfacing it.
Scope note
These are filed together because fixing only the diagnostics count leaves the silent-zero pattern and the tree-path exposure in place — the count bug is the symptom that made the other two visible.
Acceptance criteria
- A count that cannot be measured renders as unavailable, never
0; same for the other empty-vec fallbacks atdiagnostics.rs:113,166 -
nodespace diagnosticsreports the correct node count on the 31k-node database - Node counting uses an aggregate query rather than transferring rows
-
recent_node_idsuses a bounded ordered query instead of sorting a full snapshot - gRPC message limits are explicitly configured rather than inherited from the tonic default
-
get_children_treepayload growth is bounded, or a maximum supported document size is stated and enforced - A payload exceeding the limit surfaces as an actionable error at the call site, not as a plausible-looking value
- Regression coverage for the "transport failed" path asserting it does not render as a valid measurement
Activity
malibio commentedon Sep 8, 2026
Frontend: 233 test files passed, 4913 tests passed (baseline before starting work)
Bound GetChildrenTree's subtree payload with an actionable error (#2493)