Free TUI test renderers that were leaking TextBuffers (CL-5539) - #564
Merged
Merged
Conversation
list-modal.test.ts and provider-connect.test.ts never destroyed the harness renderer they created. provider-setup.test.ts was worse: ~30 mountSetup/mountLogin/createHarness call sites but only one harness.destroy() in the whole file, so nearly every test in it leaked a renderer and its TextBuffer. mouse-reporting-disabled.test.ts only freed its harness on the happy path, leaking on assertion failure. Fix: track every harness created in each file and free it in a shared afterEach, so cleanup happens regardless of which assertion fails partway through a test, matching the pattern already used elsewhere in this suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes CL-5539.
Problem
CL-5539: TUI test renderers were never freed in several test files, so a full-suite run leaked native TextBuffer handles until CI ran out and started emitting "Failed to create renderer" / "Failed to create TextBuffer".
src/tui/harness.ts'swithTestRendereralready frees correctly via try/finally, and most.test.tsfiles that callcreateHarnessdirectly already pair it with atry/finallyorbeforeAll/afterAlldestroy. Four files did not:src/tui/list-modal.test.ts— created a harness per test, never destroyed it.src/tui/provider-connect.test.ts— same, single test.src/tui/provider-setup.test.ts— the big one: ~30 call sites go throughmountSetup/mountLogin/createHarness, but the file had exactly oneharness.destroy()call. Nearly every test leaked a renderer.src/tui/mouse-reporting-disabled.test.ts— only freed its harness on the happy path (mountedHarnesses.pop()?.destroy()at the end of the test body), so a failing assertion above it would leak.Fix
In each file, track every harness created and free it in a shared
afterEach, so cleanup happens regardless of which assertion fails partway through a test. This matches the pattern already used by files in this suite that share one harness across a describe block viabeforeAll/afterAll.Verification
bun test src/tui/list-modal.test.ts src/tui/provider-connect.test.ts src/tui/provider-setup.test.ts src/tui/mouse-reporting-disabled.test.ts— 67 pass, 0 fail.bun test src/tui(full TUI suite, 118 files / 1795 tests) — 0 fail, andgrep -c "Failed to create renderer\|Failed to create TextBuffer"on the run's output is 0.provider-setup.test.tshad 30createHarnesscalls against 1destroy()call; after the fix the counts balance (every harness created is tracked and destroyed inafterEach).bun run check(lint, typecheck, build, test) — green: 5277 pass, 0 fail across 377 files.Left out / other issues noticed
permission-subagent-spansorder dependency mentioned in the ticket's "done when" list; that needs a separate pass once this lands.