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

pure usage swallows my ability to send SIGINT #2

Open
cdaringe opened this issue Jan 8, 2018 · 10 comments
Open

pure usage swallows my ability to send SIGINT #2

cdaringe opened this issue Jan 8, 2018 · 10 comments

Comments

@cdaringe
Copy link

cdaringe commented Jan 8, 2018

problem

i am unable to ctrl+c exit my program once i have run this pkg

solution

commenting out my usage of this pkg restores default node behavior

@doowb
Copy link
Member

doowb commented Jan 8, 2018

@cdaringe can you provide an example that reproduces this issue? Also, which version of node and OS are you using?

@cdaringe
Copy link
Author

cdaringe commented Jan 8, 2018

Hi @doowb, give me a couple hours, I'm at the dr! Thx for following up

@cdaringe
Copy link
Author

cdaringe commented Jan 8, 2018

@cdaringe
Copy link
Author

cdaringe commented Jan 8, 2018

Also, which version of node and OS are you using?

[email protected]
osx@high-sierra

@jonschlinkert
Copy link
Member

Is this what you mean by "pure usage"? On that line, you're creating a prompt and keeping it open (with module.exports.run()).

When a new prompt is created, it instantiates readline UI which starts listening for SIGINT.

@cdaringe
Copy link
Author

cdaringe commented Jan 8, 2018

I meant using this PKG directly vs enquirer. If you run the example you can see that even after responses are collected (prompt run() resolves and I have user input), you can't sigint the process. I keep the process up artificially with a time out such that a tester can easily verify this. By the time execution has reached that point, I should be able to sigint out out of node. Instead, however, the signal is swallowed as a side effect of running the prompt. I would think such a side effect would be removed by the time the promise resovles and user input is captured

@jonschlinkert
Copy link
Member

I would think such a side effect would be removed by the time the promise resovles and user input is captured

You'll need to close the session. This is something that enquirer does after prompts are run, but in order to allow prompts to be chained or nested, we don't close the session in individual prompts. I'm open to alternatives if you have suggestions or want to do a pull request.

I believe prompt.ui.close() would do the trick, but that's from memory. If that doesn't work we can look into it further.

@doowb
Copy link
Member

doowb commented Jan 8, 2018

I believe prompt.ui.close()

This works. I was just testing that out and about to say the same thing.

@cdaringe
Copy link
Author

cdaringe commented Jan 8, 2018

cool, ya, prompt.ui.close() was what i was looking for. thx!

I'm open to alternatives if you have suggestions or want to do a pull request

i'm still digesting this. part of me feels that when the prompt has finished... it really should be finished unless explicitly told to do so otherwise. sounds like prompt-* modules were really designed for enquirer interop though, and took defaults that worked for that module's context.

we should probably document ui.close in the README at the least, as project header states it can be used standalone. i did not expect it to effect my environment after i finished getting user input.

@romainseb
Copy link

I searched for hours to figured out where my process was stucked ( i thought it was caused by other third-part libs )
Some addition in the README might be a cool idea :)

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

No branches or pull requests

4 participants