Skip to content

Fix hanging event handler for stdin. #3218

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

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

jonasfj
Copy link
Member

@jonasfj jonasfj commented Nov 9, 2021

Piping stdin to a LineSplitter and then using a StreamQueue causes
event handler to wait for next characters after a line has been read.
Hence, if we don't exit() explicitly or hit stdin.close() then the
process will hang waiting for input on stdin.

Using stdin.readLineSync() alleviates this issue. Having a timeout on
prompts for tokens is nice, but only really required if we prompt while
the solver is running. Which we probably won't need to do anyways, so
not having a timeout is likely fine.


This should be cherry-picked for 2.15, I manually checked tool/test-bin/pub_command_runner.dart pub token add and tool/test-bin/pub_command_runner.dart pub publish against master, and this seems to fix the issue.

Piping `stdin` to a `LineSplitter` and then using a `StreamQueue` causes
event handler to wait for next characters after a line has been read.
Hence, if we don't `exit()` explicitly or hit `stdin.close()` then the
process will hang waiting for input on `stdin`.

Using `stdin.readLineSync()` alleviates this issue. Having a timeout on
prompts for tokens is nice, but only really required if we prompt while
the solver is running. Which we probably won't need to do anyways, so
not having a timeout is likely fine.
@jonasfj jonasfj requested a review from szakarias November 9, 2021 13:50
@google-cla google-cla bot added the cla: yes label Nov 9, 2021
@jonasfj jonasfj merged commit efd24e6 into dart-lang:master Nov 9, 2021
@jonasfj jonasfj deleted the fix-hanging-stdin branch November 9, 2021 14:16
jonasfj added a commit that referenced this pull request Nov 9, 2021
Piping `stdin` to a `LineSplitter` and then using a `StreamQueue` causes
event handler to wait for next characters after a line has been read.
Hence, if we don't `exit()` explicitly or hit `stdin.close()` then the
process will hang waiting for input on `stdin`.

Using `stdin.readLineSync()` alleviates this issue. Having a timeout on
prompts for tokens is nice, but only really required if we prompt while
the solver is running. Which we probably won't need to do anyways, so
not having a timeout is likely fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants