[eas-cli] Stop simulator job when start is canceled - #4113
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4113 +/- ##
==========================================
+ Coverage 62.20% 62.23% +0.03%
==========================================
Files 994 994
Lines 44716 44744 +28
Branches 9409 9415 +6
==========================================
+ Hits 27812 27840 +28
- Misses 15457 15458 +1
+ Partials 1447 1446 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Subscribed to pull request
Generated by CodeMention Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead. |
|
✅ Thank you for adding the changelog entry! |
| spinner: pollSpinner, | ||
| sessionInterrupt, | ||
| }); | ||
| return; |
There was a problem hiding this comment.
This makes cancel exit 0. Before the PR, Ctrl+C here hit Node's default SIGINT and exited 130. Now the handler swallows it and we return.
With --json that's a trap: no JSON on stdout, exit 0. SESSION=$(eas simulator:start --json | jq -r .id) gets an empty id and thinks it worked.
Can we process.exit(130) after cleanup? Exiting 0 is fine once the session is live — Ctrl+C is the point there. But here we never delivered anything.
| } | ||
|
|
||
| await sleepAsync(POLL_INTERVAL_MS); | ||
| await Promise.race([sleepAsync(POLL_INTERVAL_MS), sessionInterrupt.abortPromise]); |
There was a problem hiding this comment.
Promise.race picks a winner but doesn't cancel the loser. sleepAsync never exposes its timer handle, so nothing clears it.
On Ctrl+C the abort wins instantly, cleanup runs, we return - but the 5s timer is still pending, and Node won't exit while a timer is pending. I timed it: race settles at 1ms, process exits at 5005ms.
So the user sees "✔ Simulator session stopped", then up to 5s of nothing.
Fix: make sleep abortable so the timer gets cleared.
Then no race needed. Line 391 has the same issue, so one fix covers both.
Fixes ENG-25545.
The SIGINT handler was registered only after the simulator became ready, so canceling earlier left the Turtle job running until it timed out. This registers one handler immediately after session creation and reuses it for the whole session lifecycle.
Added a regression test and tested it live in
test-production: canceled while it was still waiting for readiness, the session never started (startedAt: null), and its final status wasSTOPPED.Also ran the targeted tests, typecheck, lint, and formatter.