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

app.prompt.get fails inside asynchronous callbacks on Windows #64

Closed
jfromaniello opened this issue May 30, 2012 · 3 comments
Closed

app.prompt.get fails inside asynchronous callbacks on Windows #64

jfromaniello opened this issue May 30, 2012 · 3 comments

Comments

@jfromaniello
Copy link

I have a weird problem that it only happens on windows. I don't know if this is the right place or if I should report it on flatiron/prompt.

Thing is that if I add a simple command like this:

var thing = module.exports,
    app = require("../../app");

thing.run = function(){
    process.nextTick(function(){
        app.prompt.get(["test"], function(e,r){
            console.log("error: " , e, " result: ", r);
        });
    });
};

to an auto generated application (with: flatiron create example cli)

when i execute the application like "simple thing run", I see the prompt message but it seems that it doesn't wait to the user data an inmediately fails with:

[Error: read Unknown system errno 6]
  code: 'Unknown system errno 6',
  errno: 'Unknown system errno 6',
  syscall: 'read' }  

The stack trace is:

prompt: test: error:  Error: read Unknown system errno 6
    at errnoException (net.js:670:11)
    at TTY.onread (net.js:395:21)

Again this only happens on windows.

Do you have any workarround to this? since I guess you do a lot of I/O in jitsu for instance.

Thank you very much, I really like flatiron

@jfromaniello
Copy link
Author

More about this... the problem seems to be related to pausing the stdin.
If I remove "stdin.pause()" from prompt.pause, it doesn't fail

@jfromaniello
Copy link
Author

I have isolated the problem to the most basic thing, first without flatiron, then without prompt, and I have come to the conclusion that the problem only happens when using the deprecated openStdin() in this line

So, to show the problem, the small code I can show is this:

process.nextTick(function(){
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('error', function (err) {
        console.log(err);
        process.exit();
    });
    process.stdin.on('data', function (chunk) {
        process.stdout.write('data: ' + chunk);
    });
});

process.openStdin();
process.stdin.pause();

This works ok in linux and fail on windows under some circunstances... It has to do with enqueing the prompt in the event loop.

I think we should close this issue here and i will open a new one on flatiorn/prompt.

@jfromaniello
Copy link
Author

moved to flatiron/prompt#34

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

1 participant