[build-tools] Soft-stop device run sessions at time limit - #4117
[build-tools] Soft-stop device run sessions at time limit#4117sjchmiela wants to merge 1 commit into
Conversation
5483a8a to
dce633e
Compare
🤖 AI code reviewDecision: Approve The specialist reviewers reported no critical or warning findings. No findings. This review is advisory — it never blocks a merge and never auto-approves. |
9492523 to
8c5da2e
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4117 +/- ##
==========================================
+ Coverage 62.46% 62.48% +0.02%
==========================================
Files 995 995
Lines 44942 44972 +30
Branches 9444 9454 +10
==========================================
+ Hits 28069 28096 +27
- Misses 15426 15429 +3
Partials 1447 1447 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a configurable “soft stop” time limit to remote device-run session steps in @expo/build-tools, allowing sessions to end gracefully (returning normally) so cleanup and always() artifact upload steps can still run, instead of relying on hard job cancellation.
Changes:
- Add optional
max_duration_secondsstep input to agent-device, Argent, and serve-sim remote-session build functions. - Implement a combined abort signal (external cancellation + duration deadline) and clear the scheduled timeout on exit.
- Extend unit tests for
waitForDeviceRunSessionStoppedAsyncto cover duration expiry, abort behavior, and timeout cleanup.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/build-tools/src/steps/utils/remoteDeviceRunSession.ts | Adds max-duration-based abort behavior to stop polling/exit cleanly and clears the duration timeout in finally. |
| packages/build-tools/src/steps/utils/tests/remoteDeviceRunSession.test.ts | Adds timer mocking and new test cases for duration expiry and timeout cleanup. |
| packages/build-tools/src/steps/functions/startServeSimRemoteSession.ts | Adds max_duration_seconds input plumbing and forwards it to the session wait helper. |
| packages/build-tools/src/steps/functions/startArgentRemoteSession.ts | Adds max_duration_seconds input plumbing and forwards it to the session wait helper. |
| packages/build-tools/src/steps/functions/startAgentDeviceRemoteSession.ts | Adds max_duration_seconds input plumbing and forwards it to the session wait helper. |
| CHANGELOG.md | Adds a release-note entry for the soft-stop behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8c5da2e to
8e549dd
Compare
8e549dd to
bc2879e
Compare
|
✅ Thank you for adding the changelog entry! |
szdziedzic
left a comment
There was a problem hiding this comment.
actually one question - what would happen here if there was a queue for free tier some time in the future?
would it make sense to make request to WWW once we really start the session to ask for time until termination to always have correct value? we can set this value as time_until_termination - some_const. Does it make sense?
Why
Currently, simulator sessions may end at hard 2h job run time limit (and we also override job run's "max run time seconds" to denote "max device run session run time"). This is bad because when job run exceeds its run time, it gets immediately killed and the worker cannot upload screen recordings.
How
Added
max_duration_secondsparam to remote-session build functions. Added duration abort controller/signal and merged it with the cancel abort signal. Whichever happens first — cancel or abort — is going to cause waiting to stop and upload artifacts and exit cleanly.Linear: https://linear.app/expo/issue/ENG-25528/soft-stop-device-run-sessions-at-time-limit
Note: this is going to lower the max run time for device run sessions in https://github.com/expo/universe/pull/29554 cause we need to stop simulator session at 2h – (time it takes to upload stuff).
Test plan
When
max_duration_secondsis not provided we do not do anything. So, we'll deploy this, add the param and see if things are ok.