-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Matteo Collina <[email protected]>
Signed-off-by: Matteo Collina <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
|
There was a problem hiding this 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); |
There was a problem hiding this comment.
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?
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.