GeezerVison is showing github.com — fix(shared): batch SQLite worker result transfers by Yash-Singh1 · Pull Request #36067 · pingdotgg/t3code
Conversation
Yash-Singh1
commented
Nov 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Problem
SQLite workers call StatementSync.all() and then clone the entire result through postMessage. Large reads therefore materialize a complete result in the worker before the server can receive it, adding memory pressure to an already busy process.
This was investigated after Nightly 0.1.10-nightly.20261113.4616 aborted with Scavenger: semi-space copy Allocation failed - JavaScript heap out of memory. The native stack included node::sqlite::StatementExecutionHelper::ColumnToValue, ExtractRowValues, and StatementSync::All on a worker thread. The database had roughly 1.96 million turn items; one thread's stored payloads totaled about 286 MB. The exact SQL executing at the crash was not recovered, so this PR does not claim that a specific query caused it.
Change
Iterate result rows in both reader and writer workers. Send batches of at most 16,384 rows, flushing earlier when estimated string/blob payload would exceed 8 MiB. Build the next batch while the parent receives the previous batch, then wait for acknowledgment before sending again. This permits one unacknowledged message plus one batch under construction without accumulating the entire result in the message queue. The parent assembles the same ordered result that callers already expect.
The byte estimate is not a heap limit, and a single oversized row remains intact. The parent still holds the complete result. This removes full-result materialization in the worker; it does not bound all server memory or SQLite's internal allocations.
Failed statements are evicted from the worker cache. Node's SQLite iterator can retain a constraint error and report it again on the next execution; preparing a fresh statement preserves recovery after a failed write.
Scope
Small fix for an observed SQLite allocation crash and an evident full-result copy in the worker implementation. No schema or public SQL API changes. The separate Cursor skill-scanning draft is unaffected.
The crash also triggered a large startup recovery backlog. Main-thread starts waited behind recovered subagent work. A separately authorized local scheduling adjustment unblocked those requests, and its original rows were preserved locally. This PR does not change recovery scheduling or include that live-state adjustment.
Verification
- Regression tests exercise real reader and writer workers with 300 rows containing 16 KiB strings, checking result ordering, object/array row shapes, and batch sizes. Before the fix, both cases failed because the worker sent one full-result message. The tests also require 10,000 narrow rows to use one message; that check failed with the initial 128-row cap.
vp test run packages/shared/src/nodeSqliteClient.test.ts apps/server/src/orchestration-v2/legacy/LegacyV1Cutover.integration.test.ts: 27 tests passed, including the migration case that initially failed CI. A new constraint-failure regression failed before the cache eviction fix and passes after it.
vp run check:changed: format, lint, both Knip checks, typechecking for 35 affected packages, and 28 tests across two files passed after the follow-up fix.
- The live crash was not reproduced, and this draft has not been installed into the running desktop app.
Local synthetic benchmarks compare the actual worker sources on Node 26.10.0, using recursive SELECTs and the same parent result assembly. Runs alternate implementation order after warmup, with 15 small-query samples, 9 narrow-result samples, and 7 large-text samples. The busy-receiver case deliberately adds 2 ms of work per received message; it is a stress model, not a production latency prediction.
| Result and receiver |
Original all() |
Initial 128-row batching |
Revised batching |
| 75 small rows, idle |
0.11 ms |
0.16 ms |
0.16 ms |
| 10,000 small rows, idle |
5.9 ms |
13.4 ms |
9.6 ms |
| 2,000 rows of 16 KiB text, idle |
14.8 ms |
11.5 ms |
8.7 ms |
| 10,000 small rows, 2 ms per delivery |
8.3 ms |
177.8 ms |
11.6 ms |
| 2,000 rows of 16 KiB text, 2 ms per delivery |
15.6 ms |
145.2 ms |
22.1 ms |
For a separate 8,000-row query with 8 KiB strings, the maximum worker heap sampled immediately before sending each message was about 70 MiB with all(), 10 MiB with the initial batches, and 27 MiB with the revised batches. This samples the worker heap, not total process memory or a continuously measured peak. The receiver still retains the complete result. The revised limit trades some memory savings for far fewer messages; narrow results still have iteration overhead compared with all().
Model: GPT-6. Harness: Codex.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Codex |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Codex |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Codex |
Live turn WebSocket decoded |
21.5 KiB |
21.5 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Codex |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
| Claude |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Claude |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Claude |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Claude |
Live turn WebSocket decoded |
21.9 KiB |
21.9 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Claude |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
Other scenarios
All 64 scenario measurements match main.
All 64 scenario measurements
| Provider |
Scenario |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
short turn resume |
WebSocket decoded |
10.5 KiB |
10.5 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Codex |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn running, cold open |
HTTP decoded |
281.7 KiB |
281.7 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Codex |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn running, history page |
HTTP decoded |
92.4 KiB |
92.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Codex |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn finished, cold open |
HTTP decoded |
381.5 KiB |
381.5 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket decoded |
381.6 KiB |
381.6 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, work page |
HTTP decoded |
186.2 KiB |
186.2 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Codex |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Codex |
idle thread resume |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell snapshot |
HTTP decoded |
42.4 KiB |
42.4 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
fleet shell subscribe |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Codex |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Codex |
stale shell reload |
HTTP decoded |
42.4 KiB |
42.4 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Codex |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
HTTP decoded |
72.4 KiB |
72.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Codex |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
short turn resume |
WebSocket decoded |
10.6 KiB |
10.6 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Claude |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn running, cold open |
HTTP decoded |
283.3 KiB |
283.3 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Claude |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn running, history page |
HTTP decoded |
93.4 KiB |
93.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Claude |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn finished, cold open |
HTTP decoded |
384.2 KiB |
384.2 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket decoded |
384.3 KiB |
384.3 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, work page |
HTTP decoded |
188.1 KiB |
188.1 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Claude |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Claude |
idle thread resume |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell snapshot |
HTTP decoded |
43.0 KiB |
43.0 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
fleet shell subscribe |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Claude |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Claude |
stale shell reload |
HTTP decoded |
43.0 KiB |
43.0 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Claude |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
HTTP decoded |
73.4 KiB |
73.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Claude |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
Baseline: e4025c8 · PR result: d11cf6a · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Approvability
Verdict: Approved at d11cf6a
Macroscope's review found this PR approvable — SQLite workers now transfer query results in acknowledged batches rather than cloning the entire result at once, reducing worker-side memory pressure. Caller-facing results and product defaults remain unchanged, with no new persistent-data operations or external exposure.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Fixed the Test Server 6 failure in 6d0ffa2. The legacy migration test exposed a Node SQLite behavior change when replacing all() with iterate(): after a constraint failure, the cached statement can report the previous error on its next execution with valid parameters. The worker now evicts failed statements from its cache.
The focused regression reproduces the stale error without the eviction and passes with it. The legacy migration integration test and the SQLite client suite pass together, and vp run check:changed passes. Current main was merged without conflicts. Waiting for CI and the automatic reviews on the new commit.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
Worker-backed SQLite queries now stream rows in acknowledged batches. The client collects the batches and returns the combined rows. Tests cover writer and reader modes, row shapes, batch limits, and reuse after a RETURNING insert fails.
Changes: SQLite result batching
| Layer / File(s) |
Summary |
Request protocol and worker batch delivery packages/shared/src/nodeSqliteClient.ts |
Requests carry a shared receipt signal. The worker iterates query results and sends batches limited to 16,384 rows or approximately 8 MiB. Intermediate replies indicate that more rows follow. Execution failures evict the cached statement. |
Client batch collection and validation packages/shared/src/nodeSqliteClient.ts, packages/shared/src/nodeSqliteClient.test.ts |
The client acknowledges intermediate batches and combines their rows before resuming the request. Tests check multiple batches, batch limits, and result shapes in writer and reader modes. A separate test verifies that a later insert succeeds after a duplicate RETURNING insert fails. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant QueryCaller
participant nodeSqliteClient
participant SQLiteWorker
QueryCaller->>nodeSqliteClient: Submit query
nodeSqliteClient->>SQLiteWorker: Send request with receipt signal
SQLiteWorker->>nodeSqliteClient: Send intermediate batch
nodeSqliteClient->>SQLiteWorker: Acknowledge batch
SQLiteWorker->>nodeSqliteClient: Send final batch
nodeSqliteClient->>QueryCaller: Resume with combined rows
Loading
Suggested reviewers: tnfssc, juliusmarminge
Merge Risk: Minimal · up to d11cf
-
SQLite worker results are now transferred in acknowledged batches, which reduces peak memory use on large result sets. No actionable merge-blocking risk remains.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title "fix(shared): batch SQLite worker result transfers" matches the main change. The PR batches worker query results instead of sending one full-result message, and the title names that change. … |
| Description check |
 |
The description follows the template. It has Problem, Change, Scope, and Verification sections, and each is substantively filled in. The Problem section explains the full-result materialization and th… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title "fix(shared): batch SQLite worker result transfers" matches the main change. The PR batches worker query results instead of sending one full-result message, and the title names that change. It uses the conventional commit format the template asks for. The title does not mention the statement-cache eviction fix, but it is not required to cover every detail.
Full details: Description check
-
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections, and each is substantively filled in. The Problem section explains the full-result materialization and the observed crash. The Change section explains batching, the acknowledgment flow, and the byte estimate limits. The Scope section says why no issue is linked and explains the scope boundary. It does not link a tracked issue, though the template asks for one to show the bug. The Verification section lists focused tests, the check run, benchmarks, and what was not checked. The model and harness line is present at the end. The description also includes a crash investigation narrative and a note about a separate live-state adjustment. That content is outside the template, but it does not stop the check from passing.
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 6d0ffa2 and d11cf6a.
Files selected for processing: 2
-
packages/shared/src/nodeSqliteClient.test.ts
packages/shared/src/nodeSqliteClient.ts
Included review availability: This review used your included allowance. 9 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Revised the batching in d11cf6a after measuring acknowledgment overhead. Batches now use an 8 MiB estimate and a 16,384-row safety cap, and the worker builds the next batch while the previous one is received. It still allows only one unacknowledged message.
With an artificial 2 ms receiver delay per delivery, the 10,000-small-row case improved from 177.8 ms to 11.6 ms, and the 2,000-large-text-row case from 145.2 ms to 22.1 ms. The original all() path measured 8.3 ms and 15.6 ms respectively, so this still has overhead. A separate 64 MiB text-result probe sampled worker heap at roughly 27 MiB, compared with 70 MiB for all() and 10 MiB for the first implementation. Full methodology and limitations are in the PR description.
The regression tests now require narrow results to avoid unnecessary batches. Both worker modes failed that assertion with the previous cap. The revised SQLite suite and migration integration test pass, and check:changed passes all checks. The live desktop installation is unchanged.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:M
30-99 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|