Repository navigation
Fix the three open bugs from TODO section 4 - #421
Merged
Merged
Conversation
MCP rxstream buffer grew without bound. handleRxData appended every RX chunk to a per-session string that only shrank when a client read the resource, so a client that subscribed and never read -- or dropped its connection without closing the session -- held the entire serial stream in main-process memory for the life of the app. RxStreamBuffer caps it at the last 1,000,000 characters, drop-oldest, and prefixes the next read with a one-line notice of how much was dropped so the reader sees a gap rather than a silent mid-line join. Trimming is amortised (runs a quarter over the cap) so a saturated stream costs one copy per 250k characters, not one per chunk. The resource description tells clients about the cap. First unit tests for main-process code. stopCpuMonitoring was an empty method with a comment saying the loop stops when the window unloads, which is not what App.cleanup is for. The requestAnimationFrame loop now records its handle and cleanup cancels it, along with any outstanding requestIdleCallback. The handles are excluded from MobX observation since they are written once per frame and nothing observes them. App.spec asserts cleanup cancels the exact frame that was pending. Find was substring-only while Filters and Highlight Rules both take regex. A findUseRegex flag and a `.*` toggle in the Find bar switch the query to a regex compiled with `g` (plus `i` unless case-sensitive). findMatches walks every hit in a row with exec, skipping zero-width matches so `x*` can neither hang nor report empty spans. An invalid pattern yields no matches and a findRegex.errorMsg the bar shows as "Invalid" with the compile error on hover. Toggling the mode resets the current match like the other find controls.
CI failed on an unhandled rejection after ConnController.characterisation.spec finished: tests that leave a serial port open start the 1s flow-control setInterval, nothing stopped it, and once vitest had torn the file down and reset the mocks it fired against getFlowControlSignals returning undefined. Locally the worker exited before the timer landed. ConnController.cleanup now stops the poll (it stopped the reconnection poller but not this one, so in the app it ran until the window unloaded). The poll callback tolerates a bad or rejected IPC response by logging, since an async interval callback has nobody to catch what it throws. The spec tears the app down after every test, and jsdom's unimplemented HTMLMediaElement.pause is stubbed once in the global setup rather than in one spec.
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 the three open items in
TODO.md§4.MCP
rxstreambuffer grew without boundhandleRxDataappended every RX chunk to a per-session string that only shrank when a client read the resource. A client that subscribed and never read, or dropped its connection without closing the session, held the entire serial stream in main-process memory for the life of the app.RxStreamBuffer(new,src/main/) caps it at the last 1,000,000 characters, drop-oldest. The next read after an overflow starts with one line saying how many characters were dropped, so the reader sees a gap rather than a silent mid-line join. Trimming is amortised: it runs when a quarter over the cap, so a saturated stream costs one string copy per ~250k characters rather than one per chunk. The resource description tells clients about the cap.These are the first unit tests for main-process code (
RxStreamBuffer.spec.ts, 5 tests) —TODO.md§6 notes there were none.stopCpuMonitoring()was a no-opThe method body was a comment saying the loop stops when the window unloads, which is not what
App.cleanup()is for. TherequestAnimationFrameloop now records its handle and cleanup cancels it, plus any outstandingrequestIdleCallback. The handles are excluded from MobX observation (written once per frame, nothing observes them).App.specasserts cleanup cancels the exact frame that was pending.Find is regex-capable
Filters and Highlight Rules both took regex; Find used
indexOf. A.*toggle in the Find bar (next toAa) switches the query to a regex compiled withg, plusiunless case-sensitive.findMatcheswalks every hit in a row withexec, skipping zero-width matches sox*can neither hang nor report empty spans. An invalid pattern yields no matches and the bar showsInvalid, with the compile error on hover. Toggling the mode resets the current match, like the other Find controls. Substring mode is unchanged.Also: a leaked interval (found by CI on this PR)
The first CI run passed all 493 tests and then failed on an unhandled rejection: tests in
ConnController.characterisation.spec.tsthat leave a serial port open start the 1 s flow-controlsetInterval, and nothing stopped it. After vitest tore the file down and reset the mocks, the timer fired againstgetFlowControlSignalsreturningundefined. Locally the worker exits before the timer lands, which is why it never showed.ConnController.cleanup()now stops the poll (it stopped the reconnection poller but not this one, so in the app it ran until the window unloaded), the poll callback logs rather than throws on a bad IPC response, and the spec tears the app down after every test.Verification
Find.spec.ts+5: every match of a pattern, case toggle in regex mode, invalid regex → no matches + error, zero-width matches, mode toggle resets cursorRxStreamBuffer.spec.ts(5): drain semantics, bounded growth, drop notice once, drain never exceeds cap, bad cap rejectedApp.spec.ts+1: cleanup cancels the pending framenpx tscclean ·npm run lint0 errors · 493/493 unit · 89/89 e2e