Conversation
- Add tests for edge cases in PoolResource and Pool.close(). - Improve internal type safety and readability in Pool implementation. - Update version to 1.5.3-wip. Fix forEach edge cases and apply optimizations - Complete resumeCompleter on cancel to prevent hangs when paused. - Stop workers early on fatal errors in forEach. - Avoid pulling items from iterator after cancellation. - Remove invalid assertion in onCancel triggered after errors. - Use onError instead of catchError for async handling. - Add tests for cancel while paused and iterator error behavior. Tests now pass on node,chrome x dart2js,dart2wasm
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with
Coverage
|
| File | Coverage |
|---|---|
| pkgs/pool/example/example.dart | 💔 Not covered |
| pkgs/pool/lib/pool.dart | 💚 100 % ⬆️ 3 % |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
Unused Dependencies ✔️
| Package | Status |
|---|---|
| pool | ✔️ All dependencies utilized correctly. |
For details on how to fix these, see dependency_validator.
This check can be disabled by tagging the PR with skip-unused-dependencies-check.
Breaking changes ✔️
| Package | Change | Current Version | New Version | Needed Version | Looking good? |
|---|---|---|---|---|---|
| pool | None | 1.5.2 | 1.5.3 | 1.5.2 | ✔️ |
This check can be disabled by tagging the PR with skip-breaking-check.
API leaks ✔️
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
| Package | Leaked API symbol | Leaking sources |
|---|
This check can be disabled by tagging the PR with skip-leaking-check.
License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
| Files |
|---|
| no missing headers |
All source files should start with a license header.
Unrelated files missing license headers
| Files |
|---|
| pkgs/bazel_worker/benchmark/benchmark.dart |
| pkgs/coverage/lib/src/coverage_options.dart |
| pkgs/html/example/main.dart |
| pkgs/html/lib/dom.dart |
| pkgs/html/lib/dom_parsing.dart |
| pkgs/html/lib/html_escape.dart |
| pkgs/html/lib/parser.dart |
| pkgs/html/lib/src/constants.dart |
| pkgs/html/lib/src/encoding_parser.dart |
| pkgs/html/lib/src/html_input_stream.dart |
| pkgs/html/lib/src/list_proxy.dart |
| pkgs/html/lib/src/query_selector.dart |
| pkgs/html/lib/src/token.dart |
| pkgs/html/lib/src/tokenizer.dart |
| pkgs/html/lib/src/treebuilder.dart |
| pkgs/html/lib/src/utils.dart |
| pkgs/html/test/dom_test.dart |
| pkgs/html/test/parser_feature_test.dart |
| pkgs/html/test/parser_test.dart |
| pkgs/html/test/query_selector_test.dart |
| pkgs/html/test/selectors/level1_baseline_test.dart |
| pkgs/html/test/selectors/level1_lib.dart |
| pkgs/html/test/selectors/selectors.dart |
| pkgs/html/test/support.dart |
| pkgs/html/test/tokenizer_test.dart |
| pkgs/html/test/trie_test.dart |
| pkgs/html/tool/generate_trie.dart |
| pkgs/pubspec_parse/test/git_uri_test.dart |
| pkgs/watcher/test/custom_watcher_factory_test.dart |
This check can be disabled by tagging the PR with skip-license-check.
There was a problem hiding this comment.
Code Review
This pull request updates the pool package to version 1.5.3-wip, introducing support for asynchronous release callbacks and improving the forEach method's handling of cancellation and iterator errors. Key changes include adding a cancellation check in the worker loop and ensuring that errors in the doneFuture trigger a cancellation of pending tasks. New tests have been added to verify resource release states, multiple close calls, and early stream termination. Feedback highlights a potential deadlock in the onCancel handler when awaiting doneFuture with a synchronous StreamController and suggests nullifying resumeCompleter after completion to prevent potential side effects.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several improvements to the pool package, including support for asynchronous release callbacks, enhanced error handling during resource processing, and better cancellation logic for streams. Additionally, it adds comprehensive tests to verify these new behaviors and edge cases. I have no feedback to provide as the changes are well-implemented and appropriately tested.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the pool package to version 1.5.3-wip, adding a usage example and significantly improving the robustness of Pool.forEach. Key changes include ensuring all workers complete before the stream closes—even during errors or cancellation—and refactoring internal resource release callbacks to support FutureOr. Feedback was provided to expand the changelog to accurately reflect these significant bug fixes and internal improvements.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
natebosch
left a comment
There was a problem hiding this comment.
We shouldn't mix cleanup with bug fixes.
Which of these tests are related to the bug fix?
| Future.sync(onRelease).then((value) { | ||
| _onReleaseCompleters.removeFirst().complete(PoolResource._(this)); | ||
| }).catchError((Object error, StackTrace stackTrace) { | ||
| }).onError((Object error, StackTrace stackTrace) { |
There was a problem hiding this comment.
move to the better typed version!
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the pool package to version 1.5.3-wip, primarily fixing Pool.forEach to ensure all workers complete before the stream is closed during errors or cancellations. It also adds a usage example and expands the test suite to cover resource release failures and multiple close calls. A critical resource leak was identified in _runOnRelease where a failed onRelease callback prevents the resource slot from being freed, potentially leading to a deadlock.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the pool package to version 1.5.3-wip, primarily fixing Pool.forEach to ensure all workers complete before the stream is closed, even in scenarios involving errors or cancellation. Additionally, it improves resource management by ensuring slots are released if allowRelease callbacks fail and adds a new example file along with extensive tests for these behaviors. I have no feedback to provide as there were no review comments to evaluate.
The only cleanup was adding the example - want me to pull that out? I figured we might as well publish, too! |
The tests have too many new cases and other edited lines to be strictly testing the change. |
| await subscription.cancel(); | ||
|
|
||
| expect(eventCount, 1 + dataSize ~/ 2); | ||
| // Because workers run in parallel, they might produce extra items in |
There was a problem hiding this comment.
This is the only unrelated changed to the forEach changes - just allows node tests to work @natebosch !
Part of this work was creating many more test cases to validate edge cases. I can remove the tests not related to the fix, if you prefer. |
Yes, it would be significantly easier to review a behavior change + tests independently from tests for behavior that is not changing. I didn't look closely at the tests yet, but test cases like |
.github/workflows/pool.yamlto use Node.js v22, enabling WasmGC support for WebAssembly tests.dart2wasmcompiler.Pool.forEachto use dual futures: one for eager error propagation and another to wait for all workers to complete before closing the stream.onCancelinforEachwaits for all active workers to release their resources even on early failure.resumeCompleterinonCancelto prevent potential double-completion.cancelwaits for all workers to finish on error.