我有一个 nodejs 脚本,它在 nodejs 12 上运行良好。我有一个新的 macbook air,我在上面安装了 nodejs LTS 14。脚本没有按预期工作,所以我将它降级到 nodejs 12 LTS。现在我收到进程内存不足的错误。我也尝试使用 --max-oud-size 来增加内存分配。
export NODE_OPTIONS=--max_old_space_size=4096
它没有用。以下是错误的堆栈跟踪
<--- Last few GCs --->
[8193:0x150008000] 41 ms: Scavenge 2.9 (4.9) -> 2.7 (5.7) MB, 0.5 / 0.0 ms (average mu = 1.000, current mu = 1.000) allocation failure
[8193:0x150008000] 54 ms: Scavenge 3.9 (5.9) -> 3.6 (8.6) MB, 0.3 / 0.0 ms (average mu = 1.000, current mu = 1.000) allocation failure
[8193:0x150008000] 59 ms: Scavenge 5.2 (8.6) -> 3.9 …Run Code Online (Sandbox Code Playgroud) 我一直在使用谷歌云功能一段时间。错误处理从来没有任何问题,但最近,当我在本地主机上停止谷歌云功能时,它给出了以下错误。
^CReceived SIGINT
Received SIGINT
^CReceived SIGINT
Received SIGTERM
^CReceived SIGINT
Run Code Online (Sandbox Code Playgroud)
一段时间后,我发现程序在执行完成后仍在执行,出现以下错误。
Error: Process exited with code 0
at process.<anonymous> (/Applications/XAMPP/xamppfiles/htdocs/web-dev/firestore-scripts/node_modules/@google-cloud/functions-framework/build/src/invoker.js:396:29)
at process.emit (events.js:310:20)
at process.EventEmitter.emit (domain.js:482:12)
at process.exit (internal/process/per_thread.js:166:15)
at Server.<anonymous> (/Applications/XAMPP/xamppfiles/htdocs/web-dev/firestore-scripts/node_modules/@google-cloud/functions-framework/build/src/invoker.js:402:29)
at Object.onceWrapper (events.js:416:28)
at Server.emit (events.js:322:22)
at Server.EventEmitter.emit (domain.js:482:12)
at emitCloseNT (net.js:1657:8)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
Run Code Online (Sandbox Code Playgroud)
很明显,我希望我的程序在按下ctrl + c 后停止,但事实并非如此。
我添加了一个 SIGINT 事件侦听器,还添加了一个 try-catch 来处理错误并向客户端发送任何类型的错误响应。它仍然无法正常工作。
目前,我正在手动终止当前的进程,这并不理想。
任何帮助表示赞赏。
javascript node.js google-cloud-platform google-cloud-functions