RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]:超出标准缓冲区最大缓冲区长度

时间:2020-05-01 10:02:26

标签: node.js meteor stdout spawn

我收到此错误enter image description here

运行此代码块时,

 reasoner = new Reasoner({
    type: 'local', 
    folder: 'csp_files' 
 });

 console.log("solving Model");
 reasoner.solve(Model, (err, stdout, stderr, isSatisfiable) => {
    console.log("isSatisfiable");
    console.log(isSatisfiable);
    if (err) {
        // manage error
        console.log("model error");
        future_response.return("model error");
    } else {
        // manage solution
        console.log(stdout);
        console.log(isSatisfiable);
        future_response.return(stdout);
    }
 });
 console.log("Model solved");
 return future_response.wait();

从我已阅读的内容中,我应该找到一种重写stdout的方法以支持更大的缓冲区长度,有人可以建议我该怎么做吗?我相信应该使用库spawn,对吗? 我使用节点版本12.16.1和流星

1 个答案:

答案 0 :(得分:1)

使用 child_process.exec 时需要使用和设置 ma​​xBuffer 选项。来自 : documentation

它是 - Node 的 child_process 的 spawn() 和 exec() 之间的区别。当您希望子进程向 Node 返回大量二进制数据时使用 spawn(),当您希望子进程返回简单的状态消息时使用 exec()。

相关问题