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

Buggy on windows 8.x with node 0.10.x #235

Closed
Fatme opened this issue Apr 20, 2015 · 9 comments
Closed

Buggy on windows 8.x with node 0.10.x #235

Fatme opened this issue Apr 20, 2015 · 9 comments

Comments

@Fatme
Copy link

Fatme commented Apr 20, 2015

Hi,

I'm using windows 8.1, node 0.10.36

var inquirer = require('inquirer');
var http = require("http");
var querystring = require("querystring");

var prompt = inquirer.createPromptModule();
function httpRequest() {
    var postData = querystring.stringify({
      'msg' : 'Hello World!'
    });

    var options = {
      hostname: 'www.google.com',
      port: 80,
      path: '/upload',
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': postData.length
      }
    };

    var req = http.request(options, function(res) {
      console.log('STATUS: ' + res.statusCode);
      console.log('HEADERS: ' + JSON.stringify(res.headers));
      res.once('data', function (chunk) {
        prompt([{
              name: 'test',
              message: 'Enter a test value in ON DATA !!!!!!',
              type: 'list',
              choices: ['Option1', 'Option2', 'Option3']
            }], function (result) {
                console.log('PROMPTER CALLBACK!');
            });
        }); 
    });

    req.on('error', function(e) { });

    // write data to request body
    req.write(postData);
    req.end();

};

httpRequest();

This renders as expected but you can't interact with it.
The problem is reproduced on Windows 8.x with node 0.10.x using cmd or git bash. I've tested it with node 0.12 and it works.

@Fatme
Copy link
Author

Fatme commented Apr 21, 2015

I forgot to mention that the script works if I use conEmu - http://sourceforge.net/projects/conemu/

@rosen-vladimirov
Copy link

@SBoudrias
Do you have any idea what might cause this issue? It's really important for us to get it working, so we are ready to help you with whatever information you need and testing of possible solutions or even workarounds.
Thanks in advance for your help!

@SBoudrias
Copy link
Owner

You can provide a minimal reproduction case. That'll help.

Then, I don't own a windows machine, so it's hard for me to reproduce and debug. But I know for a fact this was working fine and I haven't pushed new version out for a while... So I'm not sure why it stopped working.

Maybe try on older node 0.10.x?

@rosen-vladimirov
Copy link

@SBoudrias
The issue is reproducible with the code above. In fact we've simplified it to this code, in our scenario we are executing some http requests and after they finish (we use Fibers to make sure operation is completed) we use Inquirer to prompt the user for a choice. The problem is that we see the choices, but arrow keys are not working - the prompter doesn't move the selection. However we are able to write text and it is shown on the console, we can use backspace to delete it (as far as I understand, we shouldn't be able to do this when we have choices prompter). If enter is pressed, the first option is selected and the prompter is hidden (as expected, but we are unable to change the selection). You may have to run the script several times as the issue is not reproducible each time. We've tested the following scenarios:

  • Node 0.10.x on Windows 7 - everything works as expected
  • Node 0.12.x on Windows 7 - everything works as expected
  • Node 0.10.x on Windows 8 and Windows 8.1 - unable to use arrow keys
  • Node 0.12.x on Windows 8 and Windows 8.1 - everything works as expected

I've just tried with Node 0.10.10 and Node 0.10.20 - the issue is reproducible as well. We've just integrated Inquirer in our code and we've noticed the issue, so I'm not able to say if it is related to some changes in the inquirer itself with latest versions or there is some other issue.

@Fatme
Copy link
Author

Fatme commented Apr 23, 2015

I've just tested with latest changes from master branch and the result is the same - the arrow keys are not working.

@teobugslayer
Copy link

Hello @SBoudrias,

You can download a testing VirtualBox appliance with Windows 8.1 from here. It is good for 90 days and you can use it to debug the issue.

@rosen-vladimirov
Copy link

Hi @SBoudrias ,
We've investigated the issue, and we've simplified the case:

var readl = require("readline2");
var rl = readl.createInterface(process.stdin, process.stdout);
rl.on('line', function(err) {
 console.log("on line");
});

rl.on('keypress', function(err) {
 console.log("on keypress");
});

We've tried executing the script in cmd and using the arrows to see if data event is emitted from node, but when I pressed up arrow, the console showed my the previous command I've executed. It looks like node does not emit the event and the up arrow is caught by cmd itself. The issue is reproducible with both readline2 and readline and nodejs 0.10.x
Any ideas how to workaround this case?

@SBoudrias
Copy link
Owner

No idea at all, readline is Node core module. It seems to me the readline is not attached or maybe the cmd is not in tty mode... I don't know for sure.

I think you should open an issue on the Node.js repository.

@Fatme
Copy link
Author

Fatme commented Apr 27, 2015

The problem is reproducible without importing inquirer - only if we use readline module so I'm closing this issue.

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