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

Fix type loader when type check output overflows the buffer #144

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ojgarcia
Copy link

@ojgarcia ojgarcia commented Jan 29, 2025

When running the parlour CLI and you have a large amount of sorbet typecheck errors,
the parlour process will hang.

Parlour::TypeLoader uses Open3.capture3 which comes with this warning

Take care to avoid deadlocks. Output streams stdout and stderr have fixed-size buffers, so reading extensively from one but not the other can cause a deadlock when the unread buffer fills. To avoid that, stdout and stderr should be read simultaneously (using threads or IO.select).

-- https://ruby-doc.org/3.4.1/stdlibs/open3/Open3.html#method-c-popen3

The code that calls Open3.capture3 only reads from stdout. So instead of implementing a fix for this, I switched to using Open3.capture2. Which returns stdout as a string and a Process::Status object.

This change should not affect the functionality of the CLI.

popen3 requires reading from stdout and stderr simultaniouly to avoud deadlocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant