-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Comments
Ran into this. |
Ran into this as well. |
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. |
+1 |
2 similar comments
+1 |
+1 |
I have written a module that wraps the process object replacing the standard streams with tcp streams so you can use them. nw-wrap |
Was there any resolution for this? |
+1. I may be encountering this. I don't get that original error, but echo 'Hello' | nw . ...stdin just gets an const { stdin, stdout } = process;
stdin.resume();
stdin.setEncoding('utf8');
stdin
.on('data', str => {
stdout.write('Got ' + str);
})
.on('end', () => {
stdout.write('EOF');
}); |
+1 |
2 similar comments
+1 |
+1 |
+1 Any word from the team on this? It's been open for a long time. |
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 ? |
Can reproduce this issue on nwjs v0.26.6. |
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. |
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:
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: 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. |
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! |
@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 yes, will look into it. I believe the issue is mostly for Windows. |
@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. |
Appears related: #3299 |
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? |
@derrickb I'm using it on macOS Mojave with no issues. |
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. |
I'm trying to create a window that can receive input (messages) from stdin, but when I use
process.stdin
(orprocess.openStdin()
) I receive the following error:Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: