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

child process exec blocks several minutes since v0.62.0 #7851

Closed
semmel opened this issue Mar 7, 2022 · 5 comments
Closed

child process exec blocks several minutes since v0.62.0 #7851

semmel opened this issue Mar 7, 2022 · 5 comments

Comments

@semmel
Copy link

semmel commented Mar 7, 2022

NWJS Version : 0.62.0, (no error in 0.61.0)
Operating System : MacOS 11.6.4 (Big Sur), Mac OS 12.2.1 (Monterey), Windows 10

Expected behavior

exec('ls', {timeout: 2000}, callback); should return immediately and invoke the callback with the result in stdout within 1 or 2 seconds.

Actual behavior

exec('ls', {timeout: 2000}, callback); blocks the entire process for a few minutes and invokes the callback with the result in stdout also just after a few minutes

How to reproduce

  1. open the developer console.
  2. enter the code.
const exec = nw.require('child_process').exec;
exec('ls', {timeout: 2000}, (error, stdout) => {
    if (error) { 
      alert(error.message);
    }
    else {
     console.log(stdout);
   }
});

With nwjs v0.62.0 the dev console is blocked for a few minutes. With v0.61.0 there is no such blocking.

19:45:22.815 exec('ls', {timeout: 2000}, (error, stdout) => { console.log(stdout);});
19:47:18.252 ChildProcess {_events: {…}, _eventsCount: 2, _maxListeners: undefined, _closesNeeded: 3, _closesGot: 0, …}
19:47:18.276 empty.html package.json

Example Project

package.json

{
  "name": "test-child-process",
  "version": "1.0.0",
  "main": "index.html",
  "window": {
    "width": 800,
    "height": 800,
    "id":"hello-nwjs-test-app",
    "title": "Hello NWJS!"
  }
}

index.html

<!DOCTYPE html>
<html lang="DE">
<head>
   <style>
      .files {
         white-space: pre;
      }
   </style>
</head>
<body>
	<h2>Files:</h2>
   <div class="files"></div>
   
   <script>
      const 
         exec = nw.require('child_process').exec;
         cmd = process.platform === "win32" ? "dir" : "ls";
      
      exec(cmd, {timeout: 2000}, (error, stdout) => {
          if (error) { 
              alert(error.message);
          }
          else {
             document.querySelector('.files').textContent = stdout;
          }
      });
   </script>
</body>
</html>
@semmel semmel changed the title child process exec blocks several seconds since v0.62.0 child process exec blocks several minutes since v0.62.0 Mar 7, 2022
@danieltanfh95
Copy link

Same issue, works in 0.60

@adityatoshniwal
Copy link

Same issue. But I also get this on mac
Error: Value for flag --concurrent-sparkplug-max-threads= of type uint is out of bounds [[0-4294967295](tel:04294967295)]

@panther7
Copy link

panther7 commented Mar 10, 2022

Same issue, this is blocker for release...

  • Ok in 0.60.0
  • Ok in 0.61.0
  • Fail (>10 sec per exec) in 0.62.0

@rogerwang
Copy link
Member

This is fixed in git and will be available in the next nightly build.

@semmel
Copy link
Author

semmel commented Mar 14, 2022

Works great in v0.62.1 on MacOS and Windows 10!
Thanks a lot!

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

5 participants