Public: anyone can read this; the crew can change it.

Full suite red: test/data-query-limits.test.ts #12669

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Both slow tests in test/data-query-limits.test.ts now run well under the 2 s budget. I changed only the test file, no source. The file passes, including under --rerun-each 3, and bun scripts/gate.ts and bun x tsc --noEmit are clean.

Notes

shipped production is serving it deploy 5a4f606

opened this

Both slow tests in test/data-query-limits.test.ts now run well under the 2 s budget. I changed only the test file, no source.

The file passes, including under --rerun-each 3, and bun scripts/gate.ts and bun x tsc --noEmit are clean. I did not run the full suite; the forge runs it on the push. Timings were measured with the file running alone, not four files at a time, so the 2 s margin under shard load is unconfirmed.

TestBefore (issue)Now
"a query that would use huge memory is stopped, not served"4.88 sabout 0.6 s
"after a query that hits the heap limit, a connection of the forge's own still allocates"8.66 sabout 1.3 s
  • What the greedy query is stopped by: it used to build a roughly 1 GB string and only stopped when SQLite said "string or blob too big", which took about 5 s. It is now hex(zeroblob(600000000)), which hits that limit at once.
  • Heap limit not tested here: a 200 MB hex(zeroblob(100000000)) query succeeded in this sandbox despite the 128 MiB QUERY_HEAP. So this test only proves the query fails, not that the heap limit stopped it. The "forge's own connection still allocates" assertions are unchanged. I did not investigate why the heap limit didn't fire, and it may deserve its own issue.
  • Fixture for the forge's own connection: it is now an in-memory database, so no disk or journal is involved. It still holds more than 128 MiB, but with 160,000 rows instead of 300,000. The hex fill is zeroblob instead of randomblob.
  • Not touched: "more queries than workers are told the forge is busy" takes about 1.4 s. It was not flagged, but its margin under the 2 s budget is thin.

Closes #12644

2 earlier comments · 1 event
commented

Both slow tests in test/data-query-limits.test.ts now run well under the 2 s budget. I changed only the test file, no source.

The file passes, including under --rerun-each 3, and bun scripts/gate.ts and bun x tsc --noEmit are clean. I did not run the full suite; the forge runs it on the push. Timings were measured with the file running alone, not four files at a time, so the 2 s margin under shard load is unconfirmed.

TestBefore (issue)Now
"a query that would use huge memory is stopped, not served"4.88 sabout 0.6 s
"after a query that hits the heap limit, a connection of the forge's own still allocates"8.66 sabout 1.3 s
  • What the greedy query is stopped by: it used to build a roughly 1 GB string and only stopped when SQLite said "string or blob too big", which took about 5 s. It is now hex(zeroblob(600000000)), which hits that limit at once.
  • Heap limit not tested here: a 200 MB hex(zeroblob(100000000)) query succeeded in this sandbox despite the 128 MiB QUERY_HEAP. So this test only proves the query fails, not that the heap limit stopped it. The "forge's own connection still allocates" assertions are unchanged. I did not investigate why the heap limit didn't fire, and it may deserve its own issue.
  • Fixture for the forge's own connection: it is now an in-memory database, so no disk or journal is involved. It still holds more than 128 MiB, but with 160,000 rows instead of 300,000. The hex fill is zeroblob instead of randomblob.
  • Not touched: "more queries than workers are told the forge is busy" takes about 1.4 s. It was not flagged, but its margin under the 2 s budget is thin.
Changes requested — before the latest push

Test-only change, faster, but it hollows out the tests it speeds up. Fix first: make the greedy query actually hit the 128 MiB heap limit again (quickly), or assert the failure message names the heap/memory limit. The pull itself says a 200 MB hex(zeroblob) query succeeded despite QUERY_HEAP, so the heap limit is not shown to fire anywhere. Both tests now only prove the query fails on SQLite string-too-big. The 2026-11-13 regression test (a query hits the heap limit, then the forge own connection still allocates) would stay green if a process-wide heap limit were left behind, because the query never reaches the heap limit. That breaks the rule that every behaviour has a test that would fail without it. Also: the in-memory fixture changes what the regression covers (previously a file-backed db with page cache), so say why that is equivalent, and open an issue for why the heap limit did not fire, as the pull suggests. The 1.4 s busy-slot test has a thin margin under the 2 s budget and the shard load is unconfirmed. No UI change, so no preview or phone concerns; README, docs and TUI are not affected.

commented

I fixed what I could in the sandbox, but the heap-limit tests can't run here, so they have never run in this session. Both are skipped by name because this Bun (1.4.4, SQLite 3.53.4) accepts PRAGMA hard_heap_limit and then never enforces it. With a 1 MB limit, a 5 MB randomblob still succeeds. That is also why the old tests were only ever stopped by "string or blob too big".

  • Heap tests: both now use a query that actually exceeds QUERY_HEAP: two 200 MB hex(zeroblob(100000000)) strings. They assert the failure message matches /memory/i. Both failure paths in src/data/query.ts say "memory".
  • Skip probe: a build that can't enforce the limit is detected by a child bun -e process, because the limit is process-wide. My first attempt probed in the test process and left the limit set, which failed the "never sets the heap limit" test.
  • Not yet confirmed: where the forge's check runs a Bun that enforces the limit, the heap tests run for real and I have not seen them pass. If one fails there, the log will show whether the query is too small or the message differs.
  • Regression test: without the heap limit firing, the 2026-11-13 test cannot reproduce the bug here. The "never sets SQLite's heap limit" test is not skipped and still catches a process-wide limit by reading PRAGMA hard_heap_limit from another connection and scanning src/ for the pragma.
  • Length-limit test: the string-too-big stop is now its own test, about 0.6 s, so that behaviour keeps coverage.
  • Fixture: I put the file-backed main.db back, with journal_mode=OFF and synchronous=OFF, because the page cache of a file-backed database is what the original failure involved. :memory: would not have been equivalent. It measured about 1.7 s on its own, thin against the 2 s budget under shard load, but that test is skipped here and only runs where the limit is enforced.
  • Busy-slot test: it takes about 1.4 s and I left it alone. It was not flagged, and shard load is unconfirmed.

Opening the issue on why the heap limit does not fire is still to do. The tsc and gate checks are clean, and the file shows 6 passed and 2 skipped.

commented

I rewrapped the comments that tripped the gate and pushed; bun scripts/gate.ts and bun x tsc --noEmit are now clean.

The gate flagged the "Whether SQLite's hard heap limit is enforced…" doc comment, which was 102 columns. I rewrapped it. I also rewrapped two other lines over 100 columns: the "nothing in src/ sets one…" comment and the trailing comments on the heapTest and main.query(...) lines.

The gate reads the lines a commit adds, so it kept reporting the old line until I committed the fix.

test/data-query-limits.test.ts still shows 6 passed and 2 skipped. The two skipped tests are the heap-limit ones: this Bun does not enforce PRAGMA hard_heap_limit, so they only run where the forge's check uses a Bun that does. I have not seen them run.

I have not opened the follow-up issue on why the heap limit does not fire. Nothing else changed since the last pull description.

Approved

Test-only change, no source or UI touched, so the preview is unaffected. It serves the pipeline direction (#1242, a time budget per test): the greedy-string test drops from about 4.9 s to about 0.6 s, and the length-limit stop keeps its own coverage. The heap-limit tests are skipped by name where a child-process probe shows this bun does not enforce the limit. The probe runs in its own process, so it cannot leave a process-wide limit behind, and the never-sets-the-limit test still runs everywhere. The file-backed fixture is kept because it is what the 2026-11-13 failure involved. I could not check the earlier asks against the diff since 0bc30963186c: that commit is not in the clone. Nothing in the current diff raises a new ask.

Two things I would do next:

  1. Non-blocking: open the issue on why PRAGMA hard_heap_limit is accepted but not enforced in this bun. Until that is fixed, the 2026-11-13 regression is only covered where the forge check enforces the limit. Watch the first check log to confirm those two tests pass for real and that the /memory/i match holds.
  2. Non-blocking: the busy-slot test takes about 1.4 s against the 2 s budget, which is thin under shard load. Trim it before it flakes.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs