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

Process gets stuck on Windows (v4) #132

Closed
ivangabriele opened this issue Sep 30, 2019 · 11 comments · Fixed by #135
Closed

Process gets stuck on Windows (v4) #132

ivangabriele opened this issue Sep 30, 2019 · 11 comments · Fixed by #135

Comments

@ivangabriele
Copy link

ivangabriele commented Sep 30, 2019

Here is a simple example to reproduce the issue:

const ora = require("ora");

const spinner = ora();

function loop(n) {
  if (n === 10) {
    spinner.succeed(String(n));
    spinner.stop();

    return;
  }

  spinner.text = String(n);

  setTimeout(() => loop(n + 1), 250);
}

(async () => {
  const n = 0;

  spinner.start(n);

  setTimeout(() => loop(n + 1), 250);
})();

I have a feeling this is not the process in fact that is stuck since there is no Node instance running in the tasks manager once it's done, but the CLI doesn't "finish" (the spinner succeed but the cursor blinks forever) or respond to any CTRL+C. So my title is surely somehow wrong.

It does work if we add the option discardStdin: false which is how it was in v3.

@sindresorhus
Copy link
Owner

Can you make sure you're using version 4.0.2?

@ivangabriele
Copy link
Author

ivangabriele commented Sep 30, 2019

@sindresorhus 100% sure I am using 4.0.2 version (double-checked the ora version in my node_modules). And I'm under Node v12.10.0.

@sindresorhus
Copy link
Owner

// @stroncium

@ivangabriele
Copy link
Author

ivangabriele commented Sep 30, 2019

So, I further tested. And here are some interesting cases:

When the script is run via node script.js, all CLIs (Command Prompt, Powershell, Git Bash) get the cursor stuck and CTRL+C doesn't work (I have to force-close the window).

When the script is run via npm myscript which in turn runs node script.js, the cursor still gets stuck on Command Prompt and Powershell but not on Git Bash. And CTRL+C works this time though. However, on Git Bash, via the npm script, the spinner doesn't show up and only the "succeed" step does.

@michaelmerrill
Copy link

I'm also experiencing this issue after upgrading from 3.4.0 to 4.0.2. The process hangs. Downgrading version back to 3.4.0 fixes the issue. I'm on a Mac, so this isn't just a Windows issue.

@ngocdaothanh
Copy link

Probably related: #134

@ivangabriele
Copy link
Author

Thanks @ngocdaothanh, nice one ! I will test that too for my cases.

@stroncium
Copy link
Contributor

stroncium commented Oct 5, 2019

Ok, so my current understanding is:
When run as npm ... the npm handles the Ctrl+C and kills everything, the underlying node ... runs as usual.
When run as node ..., it does hang. The hanging is not related to event loop nor ora code on it's own. ora uses cli-cursor which uses restore-cursor, which uses signal-exit to write to stderr on exit. This line to write to stderr never finishes(properly hangs).

@jjalonso
Copy link

Guys, I have similar issue with a user using windows, he can close the app without issues but the problem is that the spinner doesnt show, and also appear be blocking "Enquirer" to run the prompts.

When I start the spinner I do some async work at the background, and just after I launch Enquirer prompts, but the spinner nor enquirer questions were not showing in Windows.

I changed the version of ora to 3.0.4 and all work fine.

@gilles-crealp
Copy link

FYI, I have the same problem with node script.js but not when using nodemon script.js, even if it run node script.js too...

@targos
Copy link

targos commented Nov 12, 2019

It gets stuck when this line is executed:

ora/index.js

Line 222 in 974630f

stdin.setRawMode(true);

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.

8 participants