Skip to content

fix(tui): 起動時に画面下へ出る MaxListenersExceededWarning を止める - #55

Merged
yukihamada merged 1 commit into
headless-model-fallbackfrom
fix/tui-keymap-maxlisteners
Nov 2, 2026
Merged

yukihamada merged 1 commit into
headless-model-fallbackfrom
fix/tui-keymap-maxlisteners

Conversation

@yukihamada

Copy link
Copy Markdown
Owner

症状

Sente の対話画面を開くと、画面下に次の警告が出る。
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 destroyed listeners added to [TextareaRenderable]

原因

@opentui/keymap はキー割り当て層を部品に結びつけるたびに、その部品へ destroyed 購読を1つ足す。入力欄には11層以上が正当に重なるため、Node の既定上限10を超えて警告が出る。層を外すときに購読も外れるので、リークではない。

修正

packages/tui/src/app.tsx で createDefaultOpenTuiKeymap と同じ構成の keymap を作り、onTargetDestroy のときだけ、必要な購読数に合わせて上限を引き上げる。

確認

  • 擬似端末でソースから起動して比較:修正前は警告1件、修正後は0件
  • packages/tui の型チェックが通る
  • test/keymap.test.tsx と test/app-lifecycle.test.tsx:5件成功

戻し方

このPRを revert する(変更は app.tsx の1ファイルのみ)。

🤖 Generated with Claude Code

keymap は同じ部品(入力欄 TextareaRenderable)に重ねたキー割り当て層ごとに
destroyed 購読を1つ足すため、正当に11層を超えて既定上限10の警告が出ていた。
層の解除時に off されるのでリークではない。購読数に合わせて上限だけ引き上げる。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@yukihamada
yukihamada merged commit eae2d2e into headless-model-fallback Nov 2, 2026
3 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant