Avoid mutating global STDOUT & STDERR (#1837)#1
Open
MitchLewis930 wants to merge 1 commit intopr_051_beforefrom
Open
Avoid mutating global STDOUT & STDERR (#1837)#1MitchLewis930 wants to merge 1 commit intopr_051_beforefrom
MitchLewis930 wants to merge 1 commit intopr_051_beforefrom
Conversation
Greptile OverviewGreptile SummaryModified
The change prevents side effects where creating a Puma::Events object would permanently modify the global STDOUT and STDERR sync settings, affecting other code in the same process. Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Application Code
participant Events as Puma::Events
participant STDOUT as STDOUT (constant)
participant StdoutDup as STDOUT.dup
Note over App,STDOUT: Before PR (mutates global)
App->>Events: new(STDOUT, STDERR)
Events->>STDOUT: @stdout = STDOUT
Events->>STDOUT: @stdout.sync = true
Note over STDOUT: STDOUT.sync mutated globally!
Note over App,StdoutDup: After PR (no mutation)
App->>Events: new(STDOUT, STDERR)
Events->>STDOUT: stdout.dup
STDOUT->>StdoutDup: create duplicate
Events->>StdoutDup: @stdout = dup
Events->>StdoutDup: @stdout.sync = true
Note over STDOUT: STDOUT.sync unchanged
Note over StdoutDup: Only dup is modified
|
| # in lib/puma/launcher.rb:85 | ||
| # Puma::Events is default tcp_logger for cluster mode | ||
| logger = Puma::Events.new(STDOUT, STDERR) | ||
| logger.instance_variable_set(:@stdout, $stdout) # ensure capture_process_io has access to the loggers output |
There was a problem hiding this comment.
typo in comment: 'capture_process_io' should be 'capture_subprocess_io'
Suggested change
| logger.instance_variable_set(:@stdout, $stdout) # ensure capture_process_io has access to the loggers output | |
| logger.instance_variable_set(:@stdout, $stdout) # ensure capture_subprocess_io has access to the loggers output |
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/test_tcp_logger.rb
Line: 21:21
Comment:
typo in comment: 'capture_process_io' should be 'capture_subprocess_io'
```suggestion
logger.instance_variable_set(:@stdout, $stdout) # ensure capture_subprocess_io has access to the loggers output
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR_051