-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Restore sync=true on global stdout/stderr streams #2557
Restore sync=true on global stdout/stderr streams #2557
Conversation
ed689de
to
9185bfc
Compare
Thanks. I started on a similar PR with some more stuff about deprecation/logging a warning, but I can just layer that on top of this. |
The result of this I'm in favor of. Re the name Maybe I'm getting too sensitive about naming, as I often choose poor names myself... |
This isn't technically related to redirecting the STDOUT and STDERR streams, but moving it here keeps all of the STDOUT/STDERR logic together. It seems like a more natural place to put it.
9185bfc
to
a84b1fc
Compare
Good point! I renamed the setting to |
* Restore sync=true on STDOUT/STDERR streams * Move mutation of STDOUT and STDERR streams to `redirect_io` This isn't technically related to redirecting the STDOUT and STDERR streams, but moving it here keeps all of the STDOUT/STDERR logic together. It seems like a more natural place to put it. * Add a test to ensure that STDOUT is flushed by default
Description
Fixes #2545. In Puma 5.2, Puma stopped mutating the
sync
flag on the globalSTDOUT
andSTDERR
objects. This can cause user application logs to be not flushed on every write if users were depending on this behavior. This PR restoressync
behavior for those streams to the pre-5.2 behavior. We may re-introduce the change again in 6.0 with better documentation.To verify this change, I used a Rack app that writes to stdout on every request
Start puma, piping its stdout to something that's not a TTY:
Then, send a bunch of requests
seq 100 | xargs -n 1 -I{} curl http://localhost:9292
On Puma 5.2, you can observe that no output is visible from Puma until many more requests complete.
This change introduces a config option to the config DSL, so that users can opt into making it so that puma doesn't set
sync
flag on the stdout and stderr streams. The default behavior is consistent with Puma's behavior prior to 5.2. In a future release (maybe 6.0), we may change the default or remove the option altogether.Your checklist for this pull request
[changelog skip]
or[ci skip]
to the pull request title.[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.