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 · 24 comments

Comments

Projects
None yet
@dacap

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

This comment has been minimized.

Show comment
Hide comment
@techtonik

techtonik Feb 24, 2014

Ran into this.

techtonik commented Feb 24, 2014

Ran into this.

@asarudick

This comment has been minimized.

Show comment
Hide comment
@asarudick

asarudick Apr 20, 2014

Ran into this as well.

asarudick commented Apr 20, 2014

Ran into this as well.

@Mithgol

This comment has been minimized.

Show comment
Hide comment
@Mithgol

Mithgol Apr 21, 2014

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@calebolin

calebolin commented Apr 28, 2014

+1

@vasanthps

This comment has been minimized.

Show comment
Hide comment
@vasanthps

vasanthps commented Jul 17, 2014

+1

@jr-k

This comment has been minimized.

Show comment
Hide comment
@jr-k

jr-k commented Sep 9, 2014

+1

@spelufo

This comment has been minimized.

Show comment
Hide comment
@spelufo

spelufo 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

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

This comment has been minimized.

Show comment
Hide comment
@drown-zed

drown-zed Aug 12, 2015

Was there any resolution for this?

drown-zed commented Aug 12, 2015

Was there any resolution for this?

@apoco

This comment has been minimized.

Show comment
Hide comment
@apoco

apoco 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');
    });

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

This comment has been minimized.

Show comment
Hide comment
@dev-mraj

dev-mraj commented May 3, 2016

+1

@xtecox

This comment has been minimized.

Show comment
Hide comment
@xtecox

xtecox commented May 27, 2016

+1

@adibas03

This comment has been minimized.

Show comment
Hide comment
@adibas03

adibas03 commented Feb 4, 2017

+1

@derrickb

This comment has been minimized.

Show comment
Hide comment
@derrickb

derrickb Sep 26, 2017

+1

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

derrickb commented Sep 26, 2017

+1

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

@chlp

This comment has been minimized.

Show comment
Hide comment
@chlp

chlp commented Nov 7, 2017

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

@djipco

This comment has been minimized.

Show comment
Hide comment
@djipco

djipco 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 ?

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

This comment has been minimized.

Show comment
Hide comment
@Christywl

Christywl Nov 22, 2017

Contributor

Can reproduce this issue on nwjs v0.26.6.

Contributor

Christywl commented Nov 22, 2017

Can reproduce this issue on nwjs v0.26.6.

@derrickb

This comment has been minimized.

Show comment
Hide comment
@derrickb

derrickb Dec 11, 2017

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.

derrickb commented Dec 11, 2017

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

This comment has been minimized.

Show comment
Hide comment
@djipco

djipco 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.

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

This comment has been minimized.

Show comment
Hide comment
@derrickb

derrickb 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.

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

This comment has been minimized.

Show comment
Hide comment
@djipco

djipco 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!

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

This comment has been minimized.

Show comment
Hide comment
@derrickb

derrickb May 25, 2018

@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

derrickb commented May 25, 2018

@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

This comment has been minimized.

Show comment
Hide comment
@rogerwang

rogerwang May 26, 2018

Member

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

Member

rogerwang commented May 26, 2018

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

@derrickb

This comment has been minimized.

Show comment
Hide comment
@derrickb

derrickb May 26, 2018

@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 commented May 26, 2018

@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

This comment has been minimized.

Show comment
Hide comment
@derrickb

derrickb Jun 10, 2018

Appears related: #3299

derrickb commented Jun 10, 2018

Appears related: #3299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment