Repository navigation
fix(android): engine startup timeout is a failure, not a cancellation (#95) - #99
Merged
Merged
Conversation
…#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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:ensureEngineInitializedwaited fordartReadywithwithTimeout(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:
awaitDartReadyuses withTimeoutOrNull and throwsDartEngineStartupTimeoutException(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.