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

[ BugFix ] Handle Failed Terminal Read Gracefully #164

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

ProjektGopher
Copy link
Contributor

@ProjektGopher ProjektGopher commented Sep 18, 2024

In Terminal::read() if the result of fread(STDIN) is false, indicating an error, we return an empty string.

This can be a problem. While this issue is rare, it does appear to be temporary (maybe some sort of race condition?)

The problem is that Concerns/TypedValue::trackTypedValue() expects the string $key passed to the 'on key' listener to not be empty as it expects to be able to read $key[0]. By checking that $key is not empty we can eliminate a repeated E_WARNING: Uninitialized string offset 0 from overwhelming the terminal output when encountered inside of a loop.

I've also added a safeguard in the prompt looping mechanism to continue onto the next iteration if this is encountered.

I haven't found a good way to make a test actually fail when a warning is encountered, but this configuration change shows the warning pretty clearly. And at least it is covered by a test, even if it's not returning a non-zero exitcode.

@taylorotwell taylorotwell merged commit 99f74bd into laravel:main Sep 18, 2024
6 checks passed
@ProjektGopher ProjektGopher deleted the fix/empty_terminal_read branch September 18, 2024 17:46
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.

3 participants