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

Ctrl+C is ignored on macOS #130

Closed
deftomat opened this issue Sep 23, 2019 · 7 comments · Fixed by #131
Closed

Ctrl+C is ignored on macOS #130

deftomat opened this issue Sep 23, 2019 · 7 comments · Fixed by #131

Comments

@deftomat
Copy link

Change introduced by #112 is ignoring ctrl+c on macOS.

Reverting back to v3 or using discardStdin: false fixes it.

Ora version: 4.0.1
macOS version: 10.15 Beta (Catalina)

@sindresorhus
Copy link
Owner

// @stroncium

@stroncium
Copy link
Contributor

stroncium commented Sep 23, 2019

Some googling tells me the proper way to emit Ctrl+C on Mac is Command+.(period).
However, if it is custom to support Command+C(or Ctrl+C if you got normal keyboard and it is converted in some weird way), we probably should support it.

I could try to find some mac to test it on, but it would probably be much faster if someone tests it and tells me what sequences are emitted on mac for such shortcuts when tty is read in raw mode.

@deftomat
Copy link
Author

Looks like it is somehow connected to execa.

Still not sure why it is happening but it looks like it doesn't work when I awaiting execa results and running the spinner at the same time. Without execa, it works as expected.

But, still, reverting to v3 or using discardStdin: false fix this issue.

@stroncium
Copy link
Contributor

Could you post some reduced example then(need to see ora options, execa options)? It may be the problem isn't unique to macs.

@deftomat
Copy link
Author

deftomat commented Sep 23, 2019

Sure.

Here is spinner and here is execa. You can hit ctrl+c during the "Installing transitive dependencies" and it will stop. However, when you update ora to v4, It will be ignored.

The package is quite fresh, so maybe it will not work as expected 😉

@carnesen
Copy link

I've reproduced this issue on macOS and Linux. The special handling of CTRL-C in #112 is not working as intended. I can confirm the workaround of reverting back to v3 or using discardStdin: false. This doesn't have anything to do with execa since that is neither a dependency of this project nor of mine where I encountered this issue. The issue only manifests on the SECOND spinner, not the first. Here is a simple repro script:

const Ora = require('ora');

const firstSpinner = new Ora('First spinner');
firstSpinner.start();

setTimeout(() => {
  firstSpinner.succeed();
  const secondSpinner = new Ora('Second spinner');
  secondSpinner.start();

  setTimeout(() => {
    secondSpinner.succeed();
  }, 3000);
}, 3000);

Hit CTRL-C during "First spinner" terminates the program. During "Second spinner" CTRL-C does not terminate the program as expected.

@fkysly
Copy link

fkysly commented Sep 26, 2019

So, how to fix it?

stroncium added a commit to stroncium/ora that referenced this issue Sep 26, 2019
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 a pull request may close this issue.

5 participants