Skip to content

Dev#2

Open
rwrz wants to merge 3 commits into
masterfrom
dev
Open

Dev#2
rwrz wants to merge 3 commits into
masterfrom
dev

Conversation

@rwrz

@rwrz rwrz commented Jul 6, 2026

Copy link
Copy Markdown

No description provided.

rwrz and others added 3 commits April 10, 2026 12:40
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
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