Skip to content

fix(android): engine startup timeout is a failure, not a cancellation (#95) - #99

Merged
vietnguyentuan2019 merged 1 commit into
mainfrom
fix/issue-95-engine-startup-timeout
Nov 9, 2026
Merged

vietnguyentuan2019 merged 1 commit into
mainfrom
fix/issue-95-engine-startup-timeout

Conversation

@vietnguyentuan2019

Copy link
Copy Markdown
Contributor

Refs #95.

The reporter's log (phase=worker-execution isStopped=false stopReason=-256) says WorkManager did not stop the worker, so the CancellationException came from our own code. Found it: ensureEngineInitialized waited for dartReady with withTimeout(10_000). That throws TimeoutCancellationException, which is a CancellationException, and every layer above rethrows those on purpose (executeDartCallbackInternal, DartCallbackWorker, ForegroundNativeWorker). So WorkManager saw a cancelled run instead of a failure, no retry/backoff, no failure event, periodic just got re-enqueued. Matches what was reported.

Fix: awaitDartReady uses withTimeoutOrNull and throws DartEngineStartupTimeoutException (plain IllegalStateException), so the normal failure path runs. A real cancellation of the waiting coroutine still propagates as a cancellation.

Tests: 3 JVM tests (timeout is not a CancellationException, ready signal returns normally, real cancel still propagates), ForegroundAdmissionTest still green.

Not done: no device test. There is no way to force the 10s timer on a device without adding a test hook, and no device was connected today. I haven't reproduced this on hardware, the root cause comes from the reporter's log plus reading the code. Keeping #95 open until they confirm.

…#95)

ensureEngineInitialized waited for dartReady with withTimeout(10s). The resulting
TimeoutCancellationException is a CancellationException, which executeDartCallbackInternal,
DartCallbackWorker and ForegroundNativeWorker all rethrow on purpose, so WorkManager saw a
cancelled run (isStopped=false, stopReason=-256) instead of a failure. Now awaitDartReady throws
DartEngineStartupTimeoutException (plain IllegalStateException) via withTimeoutOrNull, so the
normal failure/retry path runs. Real cancellation still propagates.

Tests: EngineStartupTimeoutTest (3, JVM). No device test: nothing can force the 10s timer on a
device without a test hook, and no device was connected.
@vietnguyentuan2019
vietnguyentuan2019 merged commit 6abb2db into main Nov 9, 2026
13 checks passed
@vietnguyentuan2019
vietnguyentuan2019 deleted the fix/issue-95-engine-startup-timeout branch November 10, 2026 23:36
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.

1 participant