Skip to content

[eas-cli] Stop simulator job when start is canceled - #4113

Open
sjchmiela wants to merge 2 commits into
mainfrom
stanley/eng-25545-stop-simulator-job-run-on-early-cancel
Open

[eas-cli] Stop simulator job when start is canceled#4113
sjchmiela wants to merge 2 commits into
mainfrom
stanley/eng-25545-stop-simulator-job-run-on-early-cancel

Conversation

@sjchmiela

@sjchmiela sjchmiela commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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 was STOPPED.

Also ran the targeted tests, typecheck, lint, and formatter.

@linear-code

linear-code Bot commented Jul 29, 2026

Copy link
Copy Markdown

ENG-25545

@sjchmiela sjchmiela changed the title Stop simulator job when start is canceled [eas-cli] Stop simulator job when start is canceled Jul 29, 2026
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.23%. Comparing base (cb0045d) to head (a3a565d).

Files with missing lines Patch % Lines
packages/eas-cli/src/commands/simulator/start.ts 75.00% 11 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sjchmiela
sjchmiela marked this pull request as ready for review July 29, 2026 16:29
@sjchmiela
sjchmiela requested a review from szdziedzic July 29, 2026 16:29
@github-actions

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
packages/eas-cli/** @douglowder

Generated by CodeMention

Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead.

@github-actions

Copy link
Copy Markdown

✅ Thank you for adding the changelog entry!

spinner: pollSpinner,
sessionInterrupt,
});
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants