Repository navigation
fix(emulator): settle gestures when the peer closes after the final point - #35329
Merged
Merged
Conversation
OrcaWin
force-pushed
the
OrcaWin/emulator-gesture-close-settlement
branch
from
October 28, 2026 22:31
9e710ca to
c88231d
Compare
OrcaWin
marked this pull request as ready for review
October 28, 2026 23:15
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
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. Comment |
[Medium impact] The PR appears safe to merge. SummaryThe PR rejects interrupted gestures when the peer closes after the final point, instead of leaving callers waiting.
|
OrcaWin
force-pushed
the
OrcaWin/emulator-gesture-close-settlement
branch
from
October 28, 2026 23:49
c88231d to
05f1827
Compare
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.
ELI5
If the simulator's gesture socket closes just after the final point is sent, report the interrupted sequence instead of leaving the caller waiting forever.
What Changed
Every socket close that happens before the gesture settles now rejects it. Previously, the close handler rejected only while
index < points.length. After the final point, a peer close canceled the only remaining completion timer and skipped rejection, so the promise could never settle.The completion timer now calls
resolve()beforews.close(). This is defensive ordering only:wsnever emits'close'synchronously from the OPEN state, so the old order would also have resolved first. Point encoding, 16 ms pacing and the existing 50 ms completion grace are unchanged.Why
The production route is
emulator.gesturethrough the bridge and iOS backend to this socket helper. A disappearing or restarting simulator peer could leave that operation pending after its stream had already closed.Trade-off
If the peer closes during the 50 ms grace after the final frame, the caller now gets
Emulator gesture stream closed before sequence completion, even though the simulator may already have applied the gesture. The success path never confirms delivery either, so rejecting is the conservative choice, and it is strictly better than hanging indefinitely.Visual Proof
N/A. This changes socket lifecycle and promise settlement; nothing presentational changed. A real loopback peer receives the final point, then closes the connection to reproduce the failure.
Testing
main. 18/18 tests pass acrossemulator-gesture-sender.test.tsandios-emulator-backend.test.ts.ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: all 21 checks passed.ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/emulator/emulator-gesture-sender.test.ts src/main/emulator/backends/ios-emulator-backend.test.ts --maxWorkers=2 ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2Review
No new timers, clients, dependencies or protocol fields. Normal completion latency is unchanged.
Only Linux loopback sockets were exercised. No physical simulator, macOS/iOS integration or Electron UI was run. Android uses its own gesture path. Remote protocol and workspace identity are unaffected. The helper still has no connection-establishment deadline; that predates this PR and is out of scope.
Agent skill upstream boundary