Skip to content

fix(core): cap ChordMatcher buffer to prevent unbounded growth#1714

Open
ionfwsrijan wants to merge 1 commit into
Karanjot786:mainfrom
ionfwsrijan:fix/issue-1711-chordmatcher-buffer
Open

fix(core): cap ChordMatcher buffer to prevent unbounded growth#1714
ionfwsrijan wants to merge 1 commit into
Karanjot786:mainfrom
ionfwsrijan:fix/issue-1711-chordmatcher-buffer

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Description

ChordMatcher stores every key press in its internal buffer without a size limit. Holding down a key floods the buffer, and the chord is never matched against the expected sequence, breaking chord detection.

Changes

  • Added maxBufferSize option (default 10) to the ChordMatcher constructor
  • Before attempting a match, checks if buffer length exceeds the limit
  • When over limit, resets the buffer, then continues to match the current key against the expected chord

Testing

  • Verified unbounded key presses no longer break chord matching
  • Buffer resets cleanly when limit is exceeded
  • Existing chord tests continue to pass

Closes #1711

The buffer grew on each partial chord match with no upper limit.
If a user typed keys matching a chord prefix indefinitely, the
buffer would grow unbounded. Added maxBufferSize (default 10)
that resets the buffer when exceeded.
@ionfwsrijan ionfwsrijan requested a review from Karanjot786 as a code owner June 21, 2026 07:40
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@ionfwsrijan, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 29 minutes and 33 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 49fcb94d-fe1a-44d1-b459-8d1cde2e17be

📥 Commits

Reviewing files that changed from the base of the PR and between 35c2213 and 5b64017.

📒 Files selected for processing (1)
  • packages/core/src/input/ChordMatcher.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added area:core @termuijs/core type:bug +10 pts. Bug fix. labels Jun 21, 2026
@ionfwsrijan

Copy link
Copy Markdown
Contributor Author

@Karanjot786 Please review this

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

Labels

area:core @termuijs/core type:bug +10 pts. Bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] ChordMatcher Internal Buffer Grows Unboundedly Without Timeout/Eviction — Memory Leak on Partial Input Sequences

1 participant