Skip to content

[build-tools] Handle detached Android emulator exits#3998

Merged
sjchmiela merged 1 commit into
mainfrom
stanley/handle-android-emulator-start-rejections
Jul 10, 2026
Merged

[build-tools] Handle detached Android emulator exits#3998
sjchmiela merged 1 commit into
mainfrom
stanley/handle-android-emulator-start-rejections

Conversation

@sjchmiela

Copy link
Copy Markdown
Contributor

Summary

Observe the detached Android emulator process promise immediately after startup so expected exits during retry cleanup do not surface as unhandled promise rejections.

The emulator is managed through adb after launch. When a startup attempt times out and cleanup kills the emulator, the underlying SpawnPromise can reject while the retry loop is handling the readiness failure. Observing the promise keeps Sentry from capturing that cleanup path as an unhandled SIGKILL while preserving the returned promise for callers that still await it later.

Test plan

  • yarn run -T oxfmt packages/build-tools/src/utils/AndroidEmulatorUtils.ts
  • yarn workspace @expo/build-tools typecheck

@sjchmiela sjchmiela changed the title Handle detached Android emulator exits [build-tools] Handle detached Android emulator exits Jul 10, 2026
@sjchmiela sjchmiela added the no changelog PR that doesn't require a changelog entry label Jul 10, 2026
@sjchmiela sjchmiela marked this pull request as ready for review July 10, 2026 13:57
@sjchmiela sjchmiela requested a review from szdziedzic July 10, 2026 13:57
@github-actions

Copy link
Copy Markdown

⏩ The changelog entry check has been skipped since the "no changelog" label is present.

@github-actions

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
**/* @douglowder

Generated by CodeMention

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

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 59.67%. Comparing base (6d02728) to head (df4cbb9).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ages/build-tools/src/utils/AndroidEmulatorUtils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3998      +/-   ##
==========================================
- Coverage   59.67%   59.67%   -0.00%     
==========================================
  Files         940      940              
  Lines       41260    41261       +1     
  Branches     8666     8666              
==========================================
  Hits        24617    24617              
- Misses      16549    16550       +1     
  Partials       94       94              

☔ 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.

Copilot AI left a comment

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.

Pull request overview

This PR prevents expected Android emulator process exits (especially those triggered during retry cleanup) from surfacing as unhandled promise rejections by proactively “observing” the detached emulator SpawnPromise immediately after launch.

Changes:

  • Attach a non-blocking asyncResult() observer to the detached emulator SpawnPromise right after unref().
  • Add inline comments documenting why the emulator promise is intentionally observed but not awaited at startup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sjchmiela sjchmiela merged commit 4b1f785 into main Jul 10, 2026
12 of 13 checks passed
@sjchmiela sjchmiela deleted the stanley/handle-android-emulator-start-rejections branch July 10, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog PR that doesn't require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants