worker_threads with node.js in nwjs

149 views Asked by At

worker_threads with node.js in nwjs (v0.77.0) crashes without error message

Here a list which versions work and where you can find the crash. It started with version v0.69.1

  • 0.77.0 ⛔
  • 0.76.1 ⛔

...

  • 0.70.0 ⛔
  • 0.69.1 ⛔
  • 0.69.0 ✅
  • 0.68.1 ✅

...

Here is my small example:

Server.js:

const wt = require('node:worker_threads');
try{
    setTimeout(function(){
        let w = new wt.Worker("./workerFile.js");
    }, 500);
}catch(err){
    console.log(err);
}

workerFile.js:

console.log("START WEB WORKER");
const fs=require('fs');
fs.writeFileSync('output.txt', "hello world");

package.json:

{
    "additional_trust_anchors": [],
    "app_name": "TestWebWorker",
    "chromium-args": "--enable-node-worker",
    "js-flags": "--enable-node-worker",
    "main": "index.html",
    "name": "testwebworker",
    "node-main": "Server.js",
    "node-remote": [],
    "nodejs": true,
    "single-instance": false,
    "version": "0.0.1",
    "webexe_settings": {
        "blacklist": "",
        "custom_script": "",
        "download_dir": "",
        "force_download": false,
        "linux-x32": false,
        "linux-x64": false,
        "mac-x64": false,
        "nw_compression_level": 0,
        "nw_version": "0.77.0",
        "output_pattern": "",
        "sdk_build": true,
        "uncompressed_folder": true,
        "whitelist": "",
        "windows-x32": false,
        "windows-x64": true
    },
    "webkit": {
        "double_tap_to_zoom_enabled": false,
        "plugin": false
    },
    "window": {
        "always_on_top": false,
        "as_desktop": true,
        "frame": true,
        "fullscreen": false,
        "id": "TestwebWorker",
        "kiosk": false,
        "kiosk_emulation": false,
        "position": "center",
        "resizable": true,
        "show": true,
        "show_in_taskbar": true,
        "title": "TestwebWorker",
        "transparent": false,
        "visible": true,
        "visible_on_all_workspaces": true
    }
}

Index.html:

<!DOCTYPE html>
<html lang="de">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>
    <script>
        document.addEventListener("keydown", function (event) {
            switch (event.which) {
                case 119: // F8
                    console.warn(event.key);
                    chrome.developerPrivate.openDevTools({ renderViewId: -1, renderProcessId: -1, extensionId: chrome.runtime.id });
                    break;
            }
        })
    </script>
    <p style="color: black">TEST WORKER</p>
</body>

</html>

Is it a bug in NWJS (https://github.com/nwjs/nw.js/issues/8082) ?

Or am I missing something?? PLEASE HELP! Thanks for your time.

1

There are 1 answers

1
sysrage On

In general, if it works with old version(s) of NW.js but fails with latest version, open an Issue in GitHub. That said, this one appears to have already been reported: https://github.com/nwjs/nw.js/issues/8082