You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a !command chain and a !prompt chain executing in parallel in the CLI, when the command exits it kills the input prompt. The bizarre thing is this doesn't happen with sensitive: true on the prompt (i.e. it happens with dialoguer::Input but not dialoguer::Password. It also doesn't happen if the !prompt is used first in the template, because when the prompt is rendered it opens the dialogue which blocks the main thread. This means the !command chain won't get rendered until the prompt is closed. I imagine if they were to truly render in parallel the ordering wouldn't matter.
My guess is this is related to the background process and dialoguer fighting over stdin or some other shared resource somehow. I tried explicitly setting .stdin(Stdio::null()) on the process but that did nothing. This is going to require some digging into dialoguer. I tried to reproduce it with the stdlib's synchronous Command API but couldn't, so I suspect it's related to it being a background async task.
Wild guess but the secure prompt is probably isolated.
I don't have enough knowledge on this matter but it may be preserving the prompt's futures/threads.
And I would consider this as a lucky edge case.
I couldn't confirm this yet but I was trying to find if sleep sends an exit code that somehow "bubbles too much", if that makes sense.
Sorry if my vocabulary is a bit approximative.
EDIT: small typo in your post I think, it should be -f repro.yml instead of -c repro.yml.
LucasPickering
changed the title
CLI input prompt exits if command in background exits
MacOS: CLI input prompt exits if command in background exits
Dec 27, 2024
Describe the bug
If you have a
!command
chain and a!prompt
chain executing in parallel in the CLI, when the command exits it kills the input prompt. The bizarre thing is this doesn't happen withsensitive: true
on the prompt (i.e. it happens withdialoguer::Input
but notdialoguer::Password
. It also doesn't happen if the!prompt
is used first in the template, because when the prompt is rendered it opens the dialogue which blocks the main thread. This means the!command
chain won't get rendered until the prompt is closed. I imagine if they were to truly render in parallel the ordering wouldn't matter.My guess is this is related to the background process and dialoguer fighting over stdin or some other shared resource somehow. I tried explicitly setting
.stdin(Stdio::null())
on the process but that did nothing. This is going to require some digging into dialoguer. I tried to reproduce it with the stdlib's synchronousCommand
API but couldn't, so I suspect it's related to it being a background async task.To Reproduce
repro.yml
:cargo run -- -f repro.yml rq login
Password:
prompt appear, then after a second (whensleep 1
exits), it will quitsensitive: true
line, you should see it work nowExpected behavior
The prompt stays open
Version (please complete the following information):
Additional context
The relevant code is:
The text was updated successfully, but these errors were encountered: