运行 iflow-cli 命令时遇到了 Node.js 堆内存溢出 的致命错误,导致命令以退出码 134 崩溃,核心问题是 Node.js 进程使用的内存超出了 V8 引擎默认的堆内存限制。

<— Last few GCs —>

[16232:000002367194F000] 174137224 ms: Scavenge (during sweeping) 2016.3 (2041.1) → 2015.7 (2053.3) MB, pooled: 0.0 MB, 21.35 / 0.00 ms (average mu = 0.695, current mu = 0.128) allocation failure;
[16232:000002367194F000] 174138911 ms: Mark-Compact (reduce) 2044.6 (2069.3) → 2042.1 (2051.9) MB, pooled: 0.0 MB, 1586.90 / 0.00 ms (+ 46.0 ms in 460 steps since start of marking, biggest step 10.0 ms, walltime since start of marking 1687 ms) (average m
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 00007FF653A5B106 node::OnFatalError+1318
2: 00007FF6545F9C67 v8::Function::NewInstance+423
3: 00007FF654408077 EVP_PKEY_asn1_set_get_priv_key+463063
4: 00007FF654405BDF EVP_PKEY_asn1_set_get_priv_key+453695
5: 00007FF6544235E0 X509_STORE_set_cleanup+5664
6: 00007FF65442230E X509_STORE_set_cleanup+846
7: 00007FF65442FF5B EVP_PKEY_meth_set_digestsign+21131
8: 00007FF65402FEEE v8::String::Utf8Value::~Utf8Value+152750
9: 000002362FE7B4FA
file:///C:/Users/m1785/AppData/Roaming/npm/node_modules/@iflow-ai/iflow-cli/bundle/entry.js:60
`).map(r=>Yee({…e,message:r})),Yee=t=>({verboseLine:Yw(t),verboseObject:t}),np=t=>{let e=typeof t==“string”?t:Hee(t);return cu(e).replaceAll(" “,” “.repeat(Wee))},Wee=2;var Kw=(t,e)=>{$s(e)&&cn({type:“command”,verboseMessage:t,verboseInfo:e})};var Xw=(t,e,r)=>{Jee(t);let o=Kee(t);return{verbose:t,escapedCommand:e,commandId:o,rawOptions:r}},Kee=t=>$s({verbose:t})?Xee++:void 0,Xee=0n,Jee=t=>{for(let e of t){if(e===!1)throw new TypeError(`The “verbose: false” option was renamed to “verbose: ‘none’”.`);if(e===!0)throw new TypeError(`The “verbose: true” option was renamed to “verbose: ‘short’”.`);if(!Zd.includes(e)&&!Qd(e)){let r=Zd.map(o=>`‘${o}’`).join(”, “);throw new TypeError(`The “verbose” option must not be ${e}. Allowed values are: ${r} or a function.`)}}};import{hrtime as Jw}from"node:process”;var ip=()=>Jw.bigint(),bv=t=>Number(Jw.bigint()-t)/1e6;var op=(t,e,r)=>{let o=ip(),{command:s,escapedCommand:a}=kw(t,e),i=Tv(r,“verbose”),n=Xw(i,a,{…r});return Kw(a,n),{command:s,escapedCommand:a,startTime:o,verboseInfo:n}};var XD=he(FL(),1);import Lre from"node:path";import KD from"node:process";import up from"node:process";import Co from"node:path";function ap(t={}){let{env:e=process.env,platform:r=process.platform}=t;return r!==“win32”?“PATH”:Object.keys(e).reverse().find(o=>o.toUpperCase()===“PATH”)||“Path”}import{promisify as Ote}from"node:util";import{execFile as bte,execFileSync as ZHe}from"node:child_process";import VL from"node:path";import{fileURLToPath as Rte}from"node:url";var r3e=Ote(bte);function cp(t){return t instanceof URL?Rte(t):t}function GL(t){return{*[Symbol.iterator](){let e=VL.resolve(cp(t)),r;for(;r!==e;)yield e,r=e,e=VL.resolve(e,“..”)}}}var n3e=10*1024*1024;var Pte=({cwd:t=up.cwd(),path:e=up.env[ap()],preferLocal:r=!0,execPath:o=up.execPath,addExecPath:s=!0}={})=>{let a=Co.resolve(cp(t)),i=[],n=e.split(Co.delimiter);return r&&Cte(i,n,a),s&&Nte(i,n,o,a),e===“”||e===Co.delimiter?`${i.join(Co.delimiter)}${e}`:[…i,e].join(Co.delimiter)},Cte=(t,e,r)=>{for(let o of GL(r)){let s=Co.join(o,“node_modules/.bin”);e.includes(s)||t.push(s)}},Nte=(t,e,r,o)=>{let s=Co.resolve(o,cp(r),“..”);e.includes(s)||t.push(s)},qL=({env:t=up.env,…e}={})=>{t={…t};let r=ap({env:t});return e.path=t[r],t[r]=Pte(e),t};import{setTimeout as Hte}from"node:timers/promises";var jL=(t,e,r)=>{let o=r?lu:uu,s=t instanceof Br?{}:{cause:t};return new o(e,s)},Br=class extends Error{},HL=(t,e)=>{Object.defineProperty(t.prototype,“name”,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,$L,{value:!0,writable:!1,enumerable:!1,configurable:!1})},zL=t=>lp(t)&&$L in t,$L=Symbol(“isExecaError”),lp=t=>Object.prototype.toString.call(t)===“[object Error]”,uu=class extends Error{};HL(uu,uu.name);var lu=class extends Error{};HL(lu,lu.name);import{constants as du}from"node:os";import{constants as wte}from"node:os";var YL=()=>{let t=KL-WL+1;return Array.from({length:t},Mte)},Mte=(t,e)=>({name:`SIGRT${e+1}`,number:WL+e,action:“terminate”,description:“Application-specific signal (realtime)”,standard:“posix”}),WL=34,KL=64;import{constants as Ite}from"node:os";var XL=[{name:“SIGHUP”,number:1,action:“terminate”,description:“Terminal closed”,standard:“posix”},{name:“SIGINT”,number:2,action:“terminate”,description:“User interruption with CTRL-C”,standard:“ansi”},{name:“SIGQUIT”,number:3,action:“core”,description:“User interruption with CTRL-\\”,standard:“posix”},{name:“SIGILL”,number:4,action:“core”,description:“Invalid machine instruction”,standard:“ansi”},{name:“SIGTRAP”,number:5,action:“core”,description:“Debugger breakpoint”,standard:“posix”},{name:“SIGABRT”,number:6,action:“core”,description:“Aborted”,standard:“ansi”},{name:“SIGIOT”,number:6,action:“core”,description:“Aborted”,standard:“bsd”},{name:“SIGBUS”,number:7,action:“core”,description:“Bus error due to misaligned, non-existing address or paging error”,standard:“bsd”},{name:“SIGEMT”,number:7,action:“terminate”,description:“Command should be emulated but is not implemented”,standard:“other”},{name:“SIGFPE”,number:8,action:“core”,description:“Floating point arithmetic error”,standard:“ansi”},{name:“SIGKILL”,number:9,action:“terminate”,description:“Forced termination”,standard:“posix”,forced:!0},{name:“SIGUSR1”,number:10,action:“terminate”,description:“Application-specific signal”,standard:“posix”},{name:“SIGSEGV”,number:11,action:“core”,description:“Segmentation fault”,standard:“ansi”},{name:“SIGUSR2”,number:12,action:“terminate”,description:“Application-specific signal”,standard:“posix”},{name:“SIGPIPE”,number:13,action:“terminate”,description:“Broken pipe or socket”,standard:“posix”},{name:“SIGALRM”,number:14,action:“terminate”,description:“Timeout or timer”,standard:“posix”},{name:“SIGTERM”,number:15,action:“terminate”,description:“Termination”,standard:“ansi”},{name:“SIGSTKFLT”,number:16,action:“terminate”,description:“Stack is empty or overflowed”,standard:“other”},{name:“SIGCHLD”,number:17,action:“ignore”,description:“Child process terminated, paused or unpaused”,standard:“posix”},{name:“SIGCLD”,number:17,action:“ignore”,description:“Child process terminated, paused or unpaused”,standard:“other”},{name:“SIGCONT”,number:18,action:“unpause”,description:“Unpaused”,standard:“posix”,forced:!0},{name:“SIGSTOP”,number:19,action:“pause”,description:“Paused”,standard:“posix”,forced:!0},{name:“SIGTSTP”,number:20,action:“pause”,description:‘Paused using CTRL-Z or “suspend”’,standard:“posix”},{name:“SIGTTIN”,number:21,action:“pause”,description:“Background process cannot read terminal input”,standard:“posix”},{name:“SIGBREAK”,number:21,action:“terminate”,description:“User interruption with CTRL-BREAK”,standard:“other”},{name:“SIGTTOU”,number:22,action:“pause”,description:“Background process cannot write to terminal output”,standard:“posix”},{name:“SIGURG”,number:23,action:“ignore”,description:“Socket received out-of-band data”,standard:“bsd”},{name:“SIGXCPU”,number:24,action:“core”,description:“Process timed out”,standard:“bsd”},{name:“SIGXFSZ”,number:25,action:“core”,description:“File too big”,standard:“bsd”},{name:“SIGVTALRM”,number:26,action:“terminate”,description:“Timeout or timer”,standard:“bsd”},{name:“SIGPROF”,number:27,action:“terminate”,description:“Timeout or timer”,standard:“bsd”},{name:“SIGWINCH”,number:28,action:“ignore”,description:“Terminal window size changed”,standard:“bsd”},{name:“SIGIO”,number:29,action:“terminate”,description:“I/O is available”,standard:“other”},{name:“SIGPOLL”,number:29,action:“terminate”,description:“Watched event”,standard:“other”},{name:“SIGINFO”,number:29,action:“ignore”,description:“Request for process information”,standard:“other”},{name:“SIGPWR”,number:30,action:“terminate”,description:“Device running out of power”,standard:“systemv”},{name:“SIGSYS”,number:31,action:“core”,description:“Invalid system call”,standard:“other”},{name:“SIGUNUSED”,number:31,action:“terminate”,description:“Invalid system call”,standard:“other”}];var Dv=()=>{let t=YL();return[…XL,…t].map(xte)},xte=({name:t,number:e,description:r,action:o,forced:s=!1,standard:a})=>{let{signals:{[t]:i}}=Ite,n=i!==void 0;return{name:t,number:n?i:e,description:r,supported:n,action:o,forced:s,standard:a}};var Lte=()=>{let t=Dv();return Object.fromEntries(t.map(Dte))},Dte=({name:t,number:e,description:r,supported:o,action:s,forced:a,standard:i})=>[t,{name:t,number:e,description:r,supported:o,action:s,forced:a,standard:i}],JL=Lte(),Ute=()=>{let t=Dv(),e=65,r=Array.from({length:e},(o,s)=>kte(s,t));return Object.assign({},…r)},kte=(t,e)=>{let r=Bte(t,e);if(r===void 0)return{};let{name:o,description:s,supported:a,action:i,forced:n,standard:c}=r;return{[t]:{name:o,number:t,description:s,supported:a,action:i,forced:n,standard:c}}},Bte=(t,e)=>{let r=e.find(({name:o})=>wte.signals[o]===t);return r!==void 0?r:e.find(o=>o.number===t)},T3e=Ute();var ZL=t=>{let e=“option `killSignal`”;if(t===0)throw new TypeError(`Invalid ${e}: 0 cannot be used.`);return tD(t,e)},eD=t=>t===0?t:tD(t,“`subprocess.kill()`'s argument”),tD=(t,e)=>{if(Number.isInteger(t))return Fte(t,e);if(typeof t==“string”)return Gte(t,e);throw new TypeError(`Invalid ${e} ${String(t)}: it must be a string or an integer.

uu: Command failed with exit code 134: “D:\nodejs\node.exe” “C:\Users\m1785\AppData\Roaming\npm\node_modules\@iflow-ai\iflow-cli\bundle\iflow.js”
at jL (file:///C:/Users/m1785/AppData/Roaming/npm/node_modules/@iflow-ai/iflow-cli/bundle/entry.js:60:2375)
at _u (file:///C:/Users/m1785/AppData/Roaming/npm/node_modules/@iflow-ai/iflow-cli/bundle/entry.js:86:1343)
at _ae (file:///C:/Users/m1785/AppData/Roaming/npm/node_modules/@iflow-ai/iflow-cli/bundle/entry.js:93:38024)
at mae (file:///C:/Users/m1785/AppData/Roaming/npm/node_modules/@iflow-ai/iflow-cli/bundle/entry.js:93:37744)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {
shortMessage: ‘Command failed with exit code 134: “D:\\nodejs\\node.exe” “C:\\Users\\m1785\\AppData\\Roaming\\npm\\node_modules\\@iflow-ai\\iflow-cli\\bundle\\iflow.js”’,
command: ‘D:\\nodejs\\node.exe C:\\Users\\m1785\\AppData\\Roaming\\npm\\node_modules\\@iflow-ai\\iflow-cli\\bundle\\iflow.js’,
escapedCommand: ‘“D:\\nodejs\\node.exe” “C:\\Users\\m1785\\AppData\\Roaming\\npm\\node_modules\\@iflow-ai\\iflow-cli\\bundle\\iflow.js”’,
cwd: ‘C:\\Users\\m1785\\Desktop\\半透明串口助手’,
durationMs: 174139662.5345,
failed: true,
timedOut: false,
isCanceled: false,
isGracefullyCanceled: false,
isTerminated: false,
isMaxBuffer: false,
isForcefullyTerminated: false,
exitCode: 134,
stdio: [ undefined, undefined, undefined, undefined ],
ipcOutput: [],
pipedFrom: []
}

Node.js v25.2.0
PS C:\Users\m1785\Desktop\半透明串口助手>

错误原因解析

  1. 核心错误FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

    Node.js 的 V8 引擎对堆内存有默认限制(64 位系统约 1.7GB,32 位约 1.4GB),iflow-cli 处理的数据量或自身代码占用的内存超出了这个限制,导致进程崩溃。

    1. 退出码 134:这是 Unix/Linux 风格的退出码,对应 SIGABRT(进程被中止),在 Windows 下同样表示 Node.js 因内存不足被强制终止。

希望iflow-cli能出一个命令扩展项目下的Node.js 的 V8 引擎对堆内存有默认限制,方便操作,另外感谢iflow-cli所有开发者、项目支持者们,能让我使用到iflow-cli

虽然通过 --max-old-space-size 增大内存限制是解决这类问题的标准、官方方案。

1 个赞

好的 这个问题我来摇人看看

1 个赞

如果是 macOS 或者 Linux

NODE_OPTIONS="--max-old-space-size=8192" iflow

或者分开设置

export NODE_OPTIONS="--max-old-space-size=8192" 单位是 MB

iflow


Windows 上

CMD

set NODE_OPTIONS=--max-old-space-size=8192 && iflow

PowerShell

$env:NODE_OPTIONS = "--max-old-space-size=8192"; iflow
4 个赞