Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker: flush stdout and stderr on exit #56428

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mcollina
Copy link
Member

@mcollina mcollina commented Jan 1, 2025

This fix an old problem I had since forever when using worker threads, stdout log lines being cut if the thread exited. This PR fixes it by bypassing backpressure if the thread is exiting.

Signed-off-by: Matteo Collina <[email protected]>
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 1, 2025
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. worker Issues and PRs related to Worker support. labels Jan 1, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 1, 2025
@nodejs-github-bot
Copy link
Collaborator

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.55%. Comparing base (ca69d0a) to head (1be4989).
Report is 45 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #56428    +/-   ##
========================================
  Coverage   88.54%   88.55%            
========================================
  Files         657      657            
  Lines      190393   190745   +352     
  Branches    36552    36612    +60     
========================================
+ Hits       168582   168908   +326     
- Misses      14998    15024    +26     
  Partials     6813     6813            
Files with missing lines Coverage Δ
lib/internal/worker/io.js 99.17% <100.00%> (+<0.01%) ⬆️

... and 46 files with indirect coverage changes

Copy link
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than linting, LGTM.

@@ -292,6 +292,9 @@ class WritableWorkerStdio extends Writable {
chunks: ArrayPrototypeMap(chunks,
({ chunk, encoding }) => ({ chunk, encoding })),
});
if (process._exiting) {
cb()
}
ArrayPrototypePush(this[kWritableCallbacks], cb);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be problems when the callback being called twice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants