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

withPrompts freezes the command line on some windows versions on node 10.2+ #43

Closed
Autre31415 opened this issue Jun 13, 2018 · 11 comments
Closed

Comments

@Autre31415
Copy link

This was quite a journey to triage!

Basically if you're running yeoman tests on Appveyor on node 10.2 or higher and you use withPrompts in a test the CI will hang indefinitely until it crashes.

See example here
And some tests here

If you're running a Windows 10 machine this will not happen locally, but if you run the tests in Windows 7 you'll see that same indefinite freeze that Appveyor fell victim to.

@mischah
Copy link
Member

mischah commented Jun 13, 2018

Thanks for reporting this. I wonder if there is anything we can do about this 🤔

@Autre31415
Copy link
Author

I did some quick debugging on this and drew the conclusion that the freeze is caused by a step in the yeoman-environment module, though I'm not able to replicate it when using a generator in Windows 7.

@luboskmetko
Copy link

I've just encountered the same issue on Windows 10 after upgrading to Node v10.13.0 recently. The test includes withPrompts. After downgrading to Node v8.12.0, the tests work again.

@Autre31415
Copy link
Author

I've just encountered the same issue on Windows 10 after upgrading to Node v10.13.0 recently. The test includes withPrompts. After downgrading to Node v8.12.0, the tests work again.

Back when I first noticed this node 10.2 was the latest and I found it odd that older versions worked (Including any 10.x prior to 10.2). Do your tests work on 10.1?

chasenlehara added a commit to donejs/generator-donejs that referenced this issue Jun 24, 2019
@vajahath
Copy link

vajahath commented Dec 25, 2019

I also faced this. I'm recording here a few of my quick findings (Windows 10/Node 13).

So when the generator is ran with this yeoman-test module, looks like the prompt promise is not getting resolved.

(generator code)

class MyGen extends Generator {
  constructor(args, opts) {
    super(args, opts);
  }

  public async prompting() {
    const qns = [
      {
        type: "input",
        name: "name",
        message: "Your project name"
      }
    ];

    // working
    console.log("before prompting");

    // the problem seems to be here..
    this.answers = await this.prompt(qns);

    // not working
    console.log("prompt response resolved");
  }
}

Looking at the source (yeoman-generator\lib\index.js) of this issue causing function, found the this.env.adapter.prompt(questions) is not getting resolved.

prompt(questions) {
  questions = promptSuggestion.prefillQuestions(this._globalConfig, questions);
  questions = promptSuggestion.prefillQuestions(this.config, questions);

  return this.env.adapter.prompt(questions) // this promise is not resolving
    .then(answers => {
      if (!this.options['skip-cache'] && !this.options.skipCache) {
        promptSuggestion.storeAnswers(this._globalConfig, questions, answers, false);
        promptSuggestion.storeAnswers(this.config, questions, answers, true);
      }

      return answers;
    });
}

The source of this this.env.adapter.prompt(questions) looks like coming from
yeoman-test\lib\adapter.js.

TestAdapter.prototype.prompt = function(questions, cb) {
  /**
   * the following line looks like causing an
   * un resolved promise.
   */ 
  var promise = this.promptModule(questions);
  promise.then(cb || _.noop);

  return promise;
};

Everything works fine when Node 8 is used.

What is even stranger is when I tried to debug this issue with VS Code Debugger (using jest) with node 10, this worked fine and I couldn't reproduce it. But without debugger this issue is there again.

Update: found these tests are passing in GitHub Actions environment (Windows 10/ Node 13). strange.

@mshima
Copy link
Member

mshima commented Jan 3, 2020

@vajahath could get to reproduce this error in GitHub Actions?

@vajahath
Copy link

vajahath commented Jan 9, 2020

@mshima I couldn't reproduce this at GitHub Actions, which is strange! When I locally run these tests with node 13, it fails and passes at GitHub Actions' environment.

@mshima
Copy link
Member

mshima commented Jan 9, 2020

@vajahath this seems to be a node.js bug that is affecting inquirer SBoudrias/Inquirer.js#767
There is a PR that should workaround this bug, but must be validated.
I got a windows machine to trace yeoman-generator problem. Don’t have it anymore.
If you could validade that PR on a windows machine. Running inquirer tests and check functionality.

@mshima
Copy link
Member

mshima commented Feb 2, 2020

Fixed on inquirer.

@mshima mshima closed this as completed Feb 2, 2020
@ronaldborman
Copy link

For those who try to use the Inquirer fix, it is reverted because of side effects. See SBoudrias/Inquirer.js#899.

@mshima
Copy link
Member

mshima commented Nov 29, 2020

I didn’t test, but seems to be fixed on node >= 14.6.0.

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

6 participants