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.stdin cannot be used #586

Open
dacap opened this issue Apr 2, 2013 · 28 comments
Open

process.stdin cannot be used #586

dacap opened this issue Apr 2, 2013 · 28 comments
Assignees
Labels

Comments

@dacap
Copy link

dacap commented Apr 2, 2013

I'm trying to create a window that can receive input (messages) from stdin, but when I use process.stdin (or process.openStdin()) I receive the following error:

Error: Implement me. Unknown stdin file type!

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@techtonik
Copy link

Ran into this.

@asarudick
Copy link

Ran into this as well.

@Mithgol
Copy link
Contributor

Mithgol commented Apr 21, 2014

Is it even possible to make such a feature so that it works across platforms? It has always seemed to me that a GUI window cannot receive anything from stdin on Windows.

@calebolin
Copy link

+1

2 similar comments
@vasanthps
Copy link

+1

@jr-k
Copy link

jr-k commented Sep 9, 2014

+1

@spelufo
Copy link

spelufo commented Oct 15, 2014

I have written a module that wraps the process object replacing the standard streams with tcp streams so you can use them. nw-wrap

@drown-zed
Copy link

Was there any resolution for this?

@apoco
Copy link

apoco commented Jan 1, 2016

+1. I may be encountering this. I don't get that original error, but process.stdin doesn't seem to receive stdin. For example, when running:

echo 'Hello' | nw .

...stdin just gets an end event. Sample reading code that just outputs EOF:

  const { stdin, stdout } = process;

  stdin.resume();
  stdin.setEncoding('utf8');
  stdin
    .on('data', str => {
      stdout.write('Got ' + str);
    })
    .on('end', () => {
      stdout.write('EOF');
    });

@dev-mraj
Copy link

dev-mraj commented May 3, 2016

+1

2 similar comments
@xtecox
Copy link

xtecox commented May 27, 2016

+1

@adibas03
Copy link

adibas03 commented Feb 4, 2017

+1

@derrickb
Copy link

+1

Any word from the team on this? It's been open for a long time.

@chlp
Copy link

chlp commented Nov 7, 2017

We can try to bypass using https://www.npmjs.com/package/nwjs-j5-fix

@djipco
Copy link

djipco commented Nov 18, 2017

We can try to bypass using https://www.npmjs.com/package/nwjs-j5-fix

I created that package but I really wish I could stop using it. Can we hope for this issue to be bumped up the priority list anytime soon @rogerwang ?

@Christywl
Copy link
Contributor

Can reproduce this issue on nwjs v0.26.6.

@derrickb
Copy link

Can reproduce on 0.27.1 on Mac, and what's worse, @cotejp's fix does not appear to work so there aren't any viable options I can find without looking at other methods for communicating with the app.

@djipco
Copy link

djipco commented Dec 14, 2017

and what's worse, @cotejp's fix does not appear to work

Your use case might be different from mine, but my little fix (nwjs-j5-fix) is still working for me in version 0.27.1.

@derrickb
Copy link

derrickb commented Dec 15, 2017

Your use case might be different from mine, but my little fix (nwjs-j5-fix) is still working for me in version 0.27.1.

Ah interesting. Well I'm glad to know that it should still be working. Would you mind posting a small snippet showing the most minimal amount of code necessary to test the fix? Do you use the readline module? What I've been trying, just to see if I can get any input at all:

nw.require('nwjs-j5-fix').fix();
var readline = nw.require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
rl.on('line', function (line) {
  alert(line);
});

My use case is I'm launching nwjs from an Adobe AIR project (probably not a typical use case, but alas...), as a NativeProcess, and am writing to the process's stdin like so:
process.standardInput.writeUTF("hello")

But haven't been able to get any indication that the input as received. I can retrieve the stdout from this process just fine. Immediately after launching the process, I do get a "standard error data" event but am not sure what exactly is triggering that.

I've also attempted launching it from another node app using child_process.spawn, but that doesn't seem to work for me either.

@djipco
Copy link

djipco commented Dec 15, 2017

The nwjs-j5-fix module fixes the issue of NW.js and Johnny-Five not being able to communicate. It does that successfully so I have not tested it under other scenarios.

You can look at the source code if you wnat to know more. As you'll see, it is very simple. I did not even bother with stdout because it is not needed in my scenario.

Cheers!

@derrickb
Copy link

@rogerwang Is there any hope of progress on this for macOS? I have a product that would benefit hugely from having this fixed, it's the only thing keeping me from switching to nw.js

@rogerwang
Copy link
Member

@derrickb yes, will look into it. I believe the issue is mostly for Windows.

@derrickb
Copy link

@rogerwang thanks Roger! I've done extensive testing and unfortunately experienced the issue on Mac as well... tested with several nw.js versions last year, and again earlier this year.

@derrickb
Copy link

Appears related: #3299

@porsager
Copy link

This also happens on macos at least, so https://github.com/djipco/nwjs-j5-fix is still required :-/

Is it a won't-fix @rogerwang ?

@derrickb
Copy link

This also happens on macos at least, so https://github.com/djipco/nwjs-j5-fix is still required :-/

Is it a won't-fix @rogerwang ?

When I tried nwjs-j5-fix on macOS, I still couldn't get stdin working. Were you able to?

@djipco
Copy link

djipco commented Apr 11, 2019

@derrickb I'm using it on macOS Mojave with no issues.

@jacobsummers
Copy link

I am experiencing a similar (if not the same) issue on Mac in the latest builds of nwjs. process.stdout appears to work as expected but process.stdin does not. what i need to work is something like this "echo foo | nw.js ", then in myappmain.js, process.stdin.read(3) should return "foo", instead it returns null. I have code that is working under node.js, leveraging "fs" and process.stdin.fd, but everything i have tried fails under nwjs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests