You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NW.js v0.69.1及以上版本使用Node.js worker_threads无报错崩溃求助

NW.js v0.69.1+版本中Node.js worker_threads无提示崩溃问题排查

版本运行情况

  • ✅ 可正常运行版本:v0.69.0、v0.68.1及更早版本
  • ⛔ 崩溃版本:v0.69.1至v0.77.0全系列版本(包括v0.70.0、v0.76.1、v0.77.0)

测试示例代码

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>

问题判断

这大概率是NW.js从v0.69.1版本开始引入的Bug。你当前的配置已经正确添加了--enable-node-worker启动参数,也开启了nodejs环境,配置层面没有明显遗漏。

内容的提问来源于stack exchange,提问作者Matthias Ma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 17:42:37