Several node.js errors and solutions are sorted as follows
node.js ERROR:EBADF, write
Recently work wrote a small project, this thought can drink tea, but let people want to lift table error appeared.
Fs.js:77
throw err; Forgot a callback but don ' t know where? Use Node_debug=fs
^
ERROR:EBADF, write
At Error (native)
wtf?! Fs.js:77? Is that where I'm going to see the kernel source code? Fortunately, the project is still small, demolition is more healthy. It was probably clear after half a day's time.
The first is the name of the error EBADF the meaning of the file descriptor with bad file descriptor error.
And ERROR:EBADF, write indicates that data is written to the wrong file descriptor.
The scenario in which this bug occurs is, in short, yes, there's A. On (' data ') event getting the data to write to FD, this time an operation threw the error I close this fd while handling the error, while the other side is still triggering the data event. I CLO SE's) FD writes the data inside. As follows:
// ...
var fd = fs.opensync (path, ' W ');
Test.on (' Data ', function (data) {
Fs.write (fd, data);
});
Test.on (' End ', function () {
Fs.close (FD);
});
Close will appear ERROR:EBADF before end, write
settimeout (function () {
Fs.close (FD);
}, 10);
// ...
Solution: So we've checked to make sure that Fs.close closes the file descriptor, and that there's no read/write after close.
ERROR:EBADF, close
Also attached in Google's process saw another similar error. This is when you do Fs.close (FD) for a variety of situations; , unfortunately, multiple situations are triggered and fs.close (FD) is invoked more than once, and there are also EBADF errors. This can occur:
Test.on (' End ', function () {
Fs.close (FD);
Fs.close (FD); One more call, and it will appear.
});
An unkind error.
Fs.js:77
throw err; Forgot a callback but don ' t know where? Use Node_debug=fs
^
ERROR:EBADF, close
At Error (native)
Solution: Still is to troubleshoot Fs.close, only this time is to ensure that a variety of processing will not repeatedly perform fs.close, or you can use Try/catch to ignore it.
ERROR:EBADF, bad file descriptor
Finally, I thought there would be ERROR:EBADF if I did the read operation after the FD failure, and the read results were not. Here's the code to try the bug:
// ...
Fs.closesync (FD);
Fs.readsync (FD, New Buffer (1024), 0, 1024);
// ...
But this error will be a lot friendlier, there will be a call stack out of it.
fs.js:552
var r = binding.read (fd, buffer, offset, length, position);
^
ERROR:EBADF, bad file descriptor
At Error (native)
At Object.fs.readSync (fs.js:552:19)
At Command.<anonymous> (/users/lellansin/documents/workspace/node/test-server/app/services/testservice.js : 40:6)
At Command.emit (events.js:110:17)
At Childprocess.emit (events.js:129:20)
At Maybeclose (child_process.js:1015:16)
At Socket.<anonymous> (child_process.js:1183:11)
At Socket.emit (events.js:107:17)
At Pipe.close (net.js:485:12)
Solution: Look at the error stack to change the code just fine.
node.js error:stdout Maxbuffer exceeded
When using the exec, execfile, Spawnsync, Execfilesync, and Execsync methods in the Child_process module, you need to be aware of the Maxbuffer items in their options parameters.
The above method builds a buffer in memory to buffer the combination of all output data, while maxbuffer specifies the buffer size. If the output exceeds the specified size, a Maxbuffer exceeded error is reported.
The solution is to perform when the estimated size is good, setting the larger maxbuffer:
var exec = require (' child_process '). exec;
var child = exec (' Ls-lah ', {
Encoding: ' UTF8 ',
timeout:0,
maxbuffer:5000 * 1024,//default 200 * 1024
Killsignal: ' Sigterm '
}, function (Err, stdout, stderr) {
Console.log (stdout);
});
Or when a spawn. On (' data ') event is triggered, the full data is obtained when the. On (' Close ') event is triggered by manually stitching the data.
Pomelo cannot call method ' Forwardmessage ' of undefined
Error message:
[2014-09-10 14:32:45.315] [DEBUG] Pomelo-[E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\components\
Connector.js] [Connector-server-1] handlemessage session id:1, msg: {"id": Ten, "type": 0, "Compressroute": 0, "route": " User.u
Serhandler.login "," body ":" {username: ' alan_1 ', Password: ' 123456 ', dev_id: ' 6984654 '} '}
[2014-09-10 14:32:45.320] [ERROR] Pomelo-[E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\server\serv
Er.js] fail to forward message:TypeError:Cannot call method ' Forwardmessage ' of undefined
At Doforward (e:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\server\server.js:334:50)
At Dispatch (E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\server\server.js:103:7)
At Next (e:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\common\service\filterservice.js:50:7)
At Service.beforefilter (E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\common\service\ Filterservi
Ce.js:65:3)
At Beforefilter (E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\server\server.js:242:8)
At Pro.globalhandle (E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\server\server.js:112:3)
At Component.globalhandle (E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\components\server.js : 74:
14)
At Handlemessage (E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\components\connector.js : 295:15)
At Null.<anonymous> (E:\svn\xjmh\trunk\src\server\game-server\node_modules\pomelo\lib\components\ Connector.js:239:5)
At Eventemitter.emit (events.js:95:17)
The pomelo Club says that RPC failed because the front-end server was having problems forwarding the message to another server. Or maybe it's handler misspelled.
Bo Master check found that in the Servers.json normal server if "Frontend" is configured: true this problem occurs. It is normal to try to remove the frontend or change it to false.