Node.js upgrade to 18.16.0 causing uncaughtException with [Error: Invalid argument] and no stack trace

huangapple go评论78阅读模式
英文:

Node.js upgrade to 18.16.0 causing uncaughtException with [Error: Invalid argument] and no stack trace

问题

升级了 Node.js 10.16.3 到 18.16.0,同时更新了我的项目的所有依赖项(npm 包)后,我遇到了一个模糊的 uncaughtException 错误:[Error: 无效参数]。这个 "错误" 没有堆栈跟踪,所以我似乎无法找出它的来源。

这个错误似乎在加载网页时触发,但有时候才会发生。即使在我的应用程序中加载最简单的页面时,它也可能触发。如果我让页面 "空闲" 一段时间,似乎更容易触发。当错误发生时,页面不会加载,浏览器仍然在 "加载",但页面永远不会提供服务。

这使我认为错误在 Express js(中间件)的某个地方弹出,但我无法确切找到是哪里。

为了尝试获取此错误的堆栈跟踪,我尝试过调试(使用集成的 Node.js 调试器,使用 "node inspect"),但这一点也没有帮助,我仍然只收到相同的消息 "[Error: 无效参数]" 而没有跟踪。

我应该如何进一步排除故障?我不知道要分享哪些代码,因为我无法确定错误的确切位置。


额外信息:我的环境(操作系统)是 Windows 10 22H2 build 19045.2965。
这是使用最新版本的 express(4.18.2)。

package.json:

{
  "name": "workload",
  "version": "1.0.0",
  "description": "工作量应用",
  "main": "app.js",
  "scripts": {
    "test": "test"
  },
  "author": "Mathieu",
  "license": "ISC",
  "dependencies": {
    "@popperjs/core": "^2.11.6",
    "body-parser": "^1.20.1",
    "bootstrap": "^5.1.3",
    "chart.js": "^4.2.0",
    "chartjs-plugin-datalabels": "^2.2.0",
    "cookie-session": "^2.0.0",
    "dotenv": "^16.0.3",
    "express": "^4.18.2",
    "jquery": "^3.6.3",
    "node-sspi": "^0.2.10",
    "pug": "^3.0.2",
    "sweetalert2": "^11.7.1",
    "tedious": "^16.1.0",
    "tedious-connection-pool2": "^2.1.0",
    "winston": "^3.8.2",
    "winston-daily-rotate-file": "^4.7.1"
  }
}
英文:

After upgrading from Node.js 10.16.3 to 18.16.0, along with updating all dependencies (npm packages) of my projects, I'm encountering a vague uncaughtException error: [Error: Invalid argument]. This "error" has no stack trace, so it seems impossible for me to find where it's coming from.
This error seems to trigger when loading the webpage, but only sometimes. Even when loading the most simple page of my app, it can trigger. It seems to trigger more frequently if I've left the page "idle" for a while. When the error occurs, the page does not load, the browser keeps "loading" but the page is never served.

This makes me think the error pops up somewhere in Express js (middleware), but I can't figure out where exactly.

In order to try to get a stack trace on this error, I've tried debugging (with the integrated node.js debugger, so using "node inspect", however this didn't help at all, I still only get the same message "[Error: Invalid argument]" without trace.

How can I troubleshoot this further? I don't know which code to share, as I can't pinpoint the exact location of the error.


Extra information: My environment (OS) is Windows 10 22H2 build 19045.2965.
This is with the latest version of express (4.18.2).

The package.json:

{
  "name": "workload",
  "version": "1.0.0",
  "description": "workload app",
  "main": "app.js",
  "scripts": {
    "test": "test"
  },
  "author": "Mathieu",
  "license": "ISC",
  "dependencies": {
    "@popperjs/core": "^2.11.6",
    "body-parser": "^1.20.1",
    "bootstrap": "^5.1.3",
    "chart.js": "^4.2.0",
    "chartjs-plugin-datalabels": "^2.2.0",
    "cookie-session": "^2.0.0",
    "dotenv": "^16.0.3",
    "express": "^4.18.2",
    "jquery": "^3.6.3",
    "node-sspi": "^0.2.10",
    "pug": "^3.0.2",
    "sweetalert2": "^11.7.1",
    "tedious": "^16.1.0",
    "tedious-connection-pool2": "^2.1.0",
    "winston": "^3.8.2",
    "winston-daily-rotate-file": "^4.7.1"
  }
}

答案1

得分: 0

我不知道为什么会发生这种情况,但与 Node-API(调用本地方法的一种方法)有关的东西可能在 Node 17 上出了问题。我将其解决方法是降级到 Node 14。

英文:

I don't know why it happens, but something related to Node-API(a method to call native) was maybe screwed on Node 17. I solved it to downgrading to Node 14.

答案2

得分: 0

我最终成功“修复”了问题,尽管我不知道问题的根本原因。

在我的情况下,我移除了@popperjs/core的依赖,因为它不再需要。我认为它以前是另一个模块的对等依赖,但现在不再是这种情况了。在移除@popperjs/core并删除node_modules文件夹,然后重新安装依赖项后,问题似乎已经解决了!

英文:

I managed to "fix" the issue eventually, although I don't know the root cause of the issue.

In my case, I removed the @popperjs/core dependency as it was no longer needed. I believe it was needed as a peer dependency for another module but this was no longer the case. After removing @popperjs/core and deleting the node_modules folder and then reinstalling the dependencies, the issue seems to be fixed!

huangapple
  • 本文由 发表于 2023年5月31日 23:01:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76374885.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定