Repository navigation
refactor(sonar): replace sequential loop waits with pollUntil helper (typescript:S9382) - #224
Merged
Merged
Conversation
SonarQube rule typescript:S9382 flags the awaits inside the RUN_READY poll loop and the capture/retry loop. Both are intentionally sequential - the fixture must be observed tick-by-tick, and each retry needs a fresh screenshot before the next pixel check - so NOSONAR markers explain why.
The visual fixture left hideOnBlur at its default of true, so any focus change after showWindow() hid the popup ~100ms later. On Windows the VISUAL_PREPARE_CMD restarts Explorer, which reliably steals focus, so the popup was gone by capture time and the check saw only the desktop behind it (window=false, windowBlack=0) on all 26 retries. Set hideOnBlur:false so the rendering fixture stays painted; it exercises rendering, not focus.
|
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.



Summary
typescript:S9382flagsawaits used sequentially inside loops, on the assumption the iterations are independent and could run concurrently. The two waits intests/visual/run.mtsare genuinely sequential, so instead of suppressing the findings we restructured the code so noawaitsits inside a loop:Changes
tests/visual/run.mts: add apollUntil(deadline, work, intervalMs)helper that runsworkimmediately, then re-runs it everyintervalMsvia a promise chain untilworkreturns false ordeadlinepasses — the awaits live inside the helper, never in a loop.tests/visual/run.mts: replace the READYwhileloop withawait pollUntil(deadline, () => !ready && child.exitCode === null, 100).tests/visual/run.mts: move the capture/pixel-check retry loop body into thepollUntilcallback (returningresult.status !== 'pass'), preserving theattemptscounter, the per-attemptconsole.log, and screenshot-failure propagation.tests/visual/run.mts: remove the// NOSONAR:typescript:S9382markers.Verification
pnpm lint(oxlint + oxfmt) — cleanpnpm typecheck— cleanpnpm test— 129/129 passingFindings