-
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
child_process.fork() issue #213
Comments
Does every method of child_process break for you or just one of the methods is broken? I can only confirm |
yeah I mean fork. -------- Original Message -------- Does every method of child_process break for you or just one of the methods is broken? I can only confirm Reply to this email directly or view it on GitHub: |
The implementation of return spawn(process.execPath, args, options); It failed in nw because we don't support to execute a A quick fix of it is to distribute a var path = require('path');
path.join(path.dirname(process.execPath), 'node.exe') |
that's only a workaround. nw.exe should have a switch to behave in the same way as upstream node.exe -------- Original Message -------- The implementation of return spawn(process.execPath, args, options); It failed in nw because we don't support to execute a A quick fix of it is to distribute a var path = require('path');
path.join(path.dirname(process.execPath), 'node.exe') Reply to this email directly or view it on GitHub: |
This patch on src/third_party/node is the workaround, tested with diff --git a/lib/child_process.js b/lib/child_process.js
index 9b31586..bf200d6 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -444,7 +444,12 @@ exports.fork = function(modulePath /*, args, options*/) {
options.stdio = options.silent ? ['pipe', 'pipe', 'pipe', 'ipc'] :
[0, 1, 2, 'ipc'];
- return spawn(process.execPath, args, options);
+ var path = require('path');
+ var nodePath = path.join(path.dirname(process.execPath), 'node');
+ if (process.platform === 'win32') {
+ nodePath += ".exe";
+ }
+ return spawn(nodePath, args, options);
}; |
is it going to be fixed to get default node behavior? |
Please change title of this issue. Just reading the issue gives a false impression about |
The issue in #1575 (please excuse the missleading title) is new (imho). Now, with the switch from 0.8.4 to 0.9.1 even the workaround or quick fix provided by zcbenz by adding the execPath parameter to fork is broken. Is it planned (in some future release) to add nodejs functionality to WebWorker or at least to fix fork in any way? Again, I think this feature is crucial to some applications, to spread heavy work to child processes. Cheers Gunnar P.S. Sorry for pushing that hard, but I am working at a program in my spare time since 5 month and with this feature broken, I can throw the whole thing in the trash :) (Or switch to some other product ....) |
@gunnar-t I'm so agree with you. Fast and responsive apps need to offload work to worker processes to achieve good performance, but regular workers is not enough, node functionality is essential. |
@rogerwang Could you please give any hint wether you plan to fix this error or not? Or maybe how hard it is to fix. Without any improvement here, I need to switch to another desktop nodejs solution. |
Would appreciate an update on this as well. For now, I can't move on to 0.9 branch to take advantage of its new features and speed improvements. |
Bump. I tried the "include node binary" hack above, but it didn't work for me ("Uncaught Error: channel closed", source: events.js (72)) and I think it could be because my worker uses modules that have a native bindings, which are built with nw-gyp instead of node-gyp. My use case: doing a bluetooth inquiry with node-bluetooth-serial-port, which has native bindings to target the host OS bluetooth stack. The inquiry has to run on the main thread, which is fine except it freezes node-webkit's UI. So, I'm forking my bluetooth scanner and having it stream inquiry results back to me, then running into this bug. |
Hey Roger, as you can see, there are lots of people that would like to use that feature. Please can you tell anything concering that matter?! Do I really have to switch to a library like messenger.js and build a communication between node-webkit and a completely different node.js process just to use "a worker-like" behaviour. That's sad.... :( |
I'd like to fix this as soon as I can. But I don't have a date. If you don't want to wait, I suggest finding commercial support in the community. |
Hi Roger, thank you for your answer. The important things was, that this feature will be fixed in the future. Right now I am fine with version 0.8.X .... Since my project will be commercial someday (maybe) I just needed the certainty to be able to update the underlying stack at a future date. Thanks again for your work! |
Just to clarify, the workaround involves embedding a Node JS runtime executable to call at runtime... |
👍 |
2 similar comments
👍 |
👍 |
👍 |
👍 plus: some claim it worked in 0.8.4, but I didn't have any luck with that version either. |
It does work for me on 0.8.4. However if you are on windows then you need
|
Yes, you're right, it does work in 0.8.4. That being said, I can now confirm it works up to 0.8.6. |
Hi Roger, can you give us an hint on where to look to fix this? |
@danieleds I'll look to fix soon. The first thing to do is to let node-webkit behave like upstream node. Thanks |
I can't get it to work. Any example is really appreciated. Hope we get web workers with nodejs soon enough :D |
I can't wait for this issue to be fixed, it makes it hard to build anything useful if backgrounding is broken. Your effort is very appreciated. |
Part of nwjs/nw.js#213
Thanks Roger. Seems to be working on my end. |
For future references: it works for Linux in node-webkit v0.10.3, but not on Windows. Details: https://groups.google.com/d/msg/node-webkit/UIh7RMNk9pQ/m2msPgSa0X4J |
yep, it is not work on windows, hope it will be fixed very soon. |
Part of nwjs/nw.js#213
finally, it's work on my windows 32bit machine. |
Hi! This feature still does not seem to work. I have tried the example here: #1575 (comment) It gives undefined as described. Does anyone have a working example code? Or alternatives? I have tried now:
var cp = require('child_process');
function fork() {
var p = cp.fork('worker');\
} It says: "Failed to load extension from ... Manifest file is missing or unreadable." So I created a manifest.json file (I doubt that it should work like that tough) - still nothing - now I get a notification that "new background process is added" - I do not think that this is what I need. I might get something wrong but I just want to run a long-time parser in the thread.
The problem with this solution for me though: I have to restructure my parsing code in order to make it break some time, so the UI will actually refresh, and it's pretty bad. Is there any suggestions / workarounds, what I am missing, how I could just run something, uses the file system to export, and just lets the main thread know when it's done? The ugly version is that I not only package nw into enigma, but putting node next to it, so it can call the parser separately - any other ideas? I am using nwjs-sdk-v0.15.2-win-x64 on windows 10 Thanks! |
@symunona NW.js detects if it needs to run as node by checking if the given argument has a |
child_process module from Node is broken. This blocks Node applications offloading work to another process.
The text was updated successfully, but these errors were encountered: