nw.js
nw.js copied to clipboard
NW.js returns wrong exit code on crash (and with process.exit(1))
NWJS Version : 0.59.0 Operating System : Windows 10 x64
Behavior
| Button (from example code) | Expected exit code | Actual exit code |
|---|---|---|
| Main window > process.exit(0); | 0 |
✔ 0 |
| Main window > process.exit(1); | 1 |
❌ 0 |
| Main window > [...Array(2**32-1)]; | Negative value | ❌ 0 |
| Iframe > chrome://crash | Negative value | ✔ -2147483645 |
| Iframe > chrome://kill | Negative value | ✔ -2147483645 |
| Iframe > [...Array(2**32-1)] | Negative value | ❌ 0 |
How to reproduce
- Start the application using
$nw = Start-Process nw.exe -Wait -PassThruon Windows to save the exit code on exiting the application - After pressing a button (NW.js crash) execute
$nw.exitcodeto view the exit code
Package.json
{
"name": "index",
"main": "index.html"
}
index.html
<!doctype html>
<html>
<head>
</head>
<body>
<iframe nwdisable nwfaketop style="display: none;"></iframe>
<h1>Main window</h1>
<button onClick="process.exit(0);">process.exit(0);</button>
<button onClick="process.exit(1);">process.exit(1);</button>
<button onClick="[...Array(2**32-1)]">[...Array(2**32-1)]</button>
<h1>Iframe (nwdisable nwfaketop)</h1>
<button onClick="document.getElementsByTagName('iframe')[0].src='chrome://crash';">chrome://crash</button>
<button onClick="document.getElementsByTagName('iframe')[0].src='chrome://kill';">chrome://kill</button>
<button onClick="document.getElementsByTagName('iframe')[0].src='array.html';">[...Array(2**32-1)]</button>
</body>
</html>
array.html
<!doctype html>
<html>
<head>
<script>
[...Array(2**32-1)]
</script>
</head>
<body>
</body>
</html>