child process `exec` blocks several minutes since v0.62.0
See original GitHub issueNWJS 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
- open the developer console.
- 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>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Child process | Node.js v19.3.0 Documentation
exec () : spawns a shell and runs a command within that shell, passing the stdout and stderr to a callback function when...
Read more >NW.js v0.62.1 Released with Node.js v17.7.1 and Chromium ...
NW.js 0.62.1 is here with Node.js v17.7.1 and Chromium update. ... Fix: child process exec blocks several minutes since v0.62.0 (#7851).
Read more >nodejs child_process child process run twice - Stack Overflow
In nodejs, i create a child process to execute a cmd command.It executed successfully,but after two minutes, it execute again.
Read more >Flux release notes | Flux 0.x Documentation
Bug fixes. Update the toUInt() test to use the correct conversion behavior. Prevent the Flux formatter from losing precision on float values.
Read more >Think Java - Green Tea Press
ˆ Muhammad Saied translated the book into Arabic and found several errors in the process. ˆ Marius Margowski found an inconsistency in a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is fixed in git and will be available in the next nightly build.
Works great in
v0.62.1
on MacOS and Windows 10! Thanks a lot!