Skip to content

fix(terminal): remove host listeners during cleanup - #214

Open
vincentkoc wants to merge 1 commit into
coder:mainfrom
vincentkoc:fix/host-listener-cleanup-20261104
Open

vincentkoc wants to merge 1 commit into
coder:mainfrom
vincentkoc:fix/host-listener-cleanup-20261104

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 4, 2026 •

Copy link
Copy Markdown

Summary

Disposing a terminal, or failing partway through open(), left two listeners on the host element. beforeinput kept cancelling editing, and a reused host could invoke disposed terminals' custom wheel callbacks.

Keep a stable host-only beforeinput handler and remove it in cleanupComponents(). Remove the wheel handler with the same capture setting used during registration. Child input behavior and unrelated host listeners are preserved.

This complements the document-listener cleanup in PR #206; it only changes the two host listeners.

Validation

Validated signed commit 58fdf6ae4825269f2397f07fca33f1987757ffe6 with Bun 1.4.4 and Zig 0.15.2:

  • bun run fmt, bun run lint, bun run typecheck, bun test, and bun run build pass: 375 tests, 4,608 assertions.
  • Fresh WASM from the pinned Ghostty submodule: 423,939 bytes, within the existing 512 KiB CI limit.
  • Real Chromium 151 with actual WASM/canvas reproduces both leaks on the unchanged baseline and verifies cleanup after disposal, three host-reuse cycles, and a renderer exception during opening. Open-terminal cancellation, child input, and unrelated listeners remain intact.
  • Happy DOM regression tests cover the same lifecycle cases. Its event implementation does not enforce the capture flag during listener removal, so the wheel-capture regression was also checked in Chromium.

Hosted CI and PR title validation await upstream maintainer approval; no hosted jobs have run. The validation above completed on an isolated Linux machine.

No version or dependency changes. Release notes use the repository's conventional-commit/release-please workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant