Conversation
Cancelable.fromFuture, _completeError, thenNext, and mergeAll could all throw "Bad state: Future already completed" when cancel() raced with the wrapped Future resolving. Added isCompleted guards before every completer.complete/completeError call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…m-up PR dsrenesanse#126 (refactor_issue_124) regressed _schedule() in two ways that crash init() on the default dynamicSpawning: false path, bricking app startup: - It deleted the `if (_queue.isEmpty) { ... return; }` guard right before `_queue.removeFirst()`, so removeFirst() throws `StateError: No element` on the empty PriorityQueue. - `_ensureWorkersInitialized()` warms up with `i <= min(poolSize, queueSize)`. At init the queue is empty, so min(N, 0) == 0, but the `<=` bound still runs one iteration and calls _schedule() with nothing to dequeue -> crash. _schedule() is also called speculatively at the tail of every drain (a just-freed worker + empty queue via whenComplete), so the missing guard bit beyond init too. The PR's own test only covered dynamicSpawning: true, which skips both paths. Restore the empty-queue guard and make the warm-up loop bound strict (`<`). Add test/init_with_empty_queue_test.dart covering the non-dynamic init() path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hz16YUNUjSgMq1zZfPFdFJ
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.
No description provided.