fix(turbopack-node): incorrect idle_workers stats #82
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.
This pull request refactors the worker creation and tracking logic in the Node.js pool, with a focus on simplifying how pending worker creations are managed and improving the robustness of worker statistics updates. The main changes are grouped into two themes: improvements to statistics handling and simplification of the worker creation queue.
Improvements to statistics handling:
saturating_subin theNodeJsPoolStatsmethods to prevent underflow when decrementing counters such asbooting_workers,workers, andqueued_tasks. [1] [2]Simplification of the worker creation queue:
PENDING_CREATIONSto store only theoneshot::Sender<u32>instead of a tuple withWorkerOptions, reducing unnecessary data storage.create_workerandworker_createdto match the new structure ofPENDING_CREATIONS, simplifying the push and pop operations and removing redundant code related toWorkerOptions. [1] [2]WorkerOptionstonapi_optionsearly increate_workerfor cleaner code and more explicit handling of options.