Node:child_process.js:427 throw new TypeError(“This handle type can not be sent”);
在subprocess中使用process.send时出现错误,如下所示:
process.send(someObject, function() { .... });
subprocess创build如下:
var child = require('child_process'); var forkedProcess = child.fork(nodeScriptFile);
错误是:
child_process.js:427 throw new TypeError("This handle type can't be sent"); ^ TypeError: This handle type can't be sent
程序在一台服务器上正常工作。 我试图通过复制所有文件创build一个单独的生产服务器,我开始得到这个错误。 当然,还有更多的程序,那么上面显示的代码。 我觉得我忽略了一些安装或者一些小事。 我看着child-process.js代码,并从这个代码触发错误:
if (handle instanceof net.Socket) { message.type = 'net.Socket'; } else if (handle instanceof net.Server) { message.type = 'net.Server'; } else if (handle instanceof process.binding('tcp_wrap').TCP || handle instanceof process.binding('pipe_wrap').Pipe) { message.type = 'net.Native'; } else if (handle instanceof dgram.Socket) { message.type = 'dgram.Socket'; } else if (handle instanceof process.binding('udp_wrap').UDP) { message.type = 'dgram.Native'; } else { throw new TypeError("This handle type can't be sent"); }
花了相当多的时间…请帮助!
在旧版本的Node中(0.10或者0.12), process.send()
是同步的,所以它不接受callback函数。 但是,它确实接受了一个可选的第二个参数sendHandle
。
在你的情况下,你使用的是较旧的Node版本,因为你的callback函数参数不是.send()
一个有效参数,所以抛出了错误,因此它通过了你显示的所有handle instanceof ...
testing你的问题。
- Tesseract Node.js – 使用“lang”选项导致崩溃
- npm install mysql删除其他50个node_modules包?
- 节点检测来自用户代理的不安全浏览器
- nodeJS什么时候检查执行callback的callback队列?
- Passport身份validationfunction在节点API中不起作用
- MongoDb,NodeJs,Express和Angular 2,来自两个集合的数据join,复制和显示
- Node / Grunt – Autoprefixer – 如何添加configuration到我的Gruntfile.js&如何检查支持的浏览器?
- 如何将客户端关联的数据存储在socket.io 1.0中
- 在node.js程序上访问github api时请求禁止