I've faced a incomprehensible uncaught exception in my tcp server program based on node.
Here is its call-stack.
stack=[TypeError: Cannot call method 'close' of null,
at Socket._destroy (net.js:463:18),
at Socket.destroy (net.js:490:8),
at Socket.onSocketFinish (net.js:204:17),
at Socket.emit (events.js:92:17),
at finishMaybe (_stream_writable.js:360:12),
at endWritable (_stream_writable.js:367:3),
at Socket.Writable.end (_stream_writable.js:345:5),
at Socket.end (net.js:396:31),
at Socket.destroySoon (net.js:422:10),
at Socket.onSocketEnd (net.js:262:10),
at Socket.emit (events.js:92:17),
at TCP.onread (net.js:554:10)]
And here is the related source code on net.js
431 Socket.prototype._destroy = function(exception, cb) {
432 debug('destroy');
433
...
458 debug('close');
459 if (this._handle) { <-- check 'this._handle' is null
460 if (this !== process.stderr)
461 debug('close handle');
462 var isException = exception ? true : false;
463 this._handle.close(function() { <-- so,'this._handle' cannot be null
464 debug('emit close');
465 self.emit('close', isException);
466 });
467 this._handle.onread = noop;
468 this._handle = null;
469 }
The control flow of this node code block is synchronous, so the uncaught exception is not possible. But it happened...
Do you have any idea for this situation?
< Updates >
node version is 0.10.26
And I don't know which code on my sources invokes this exception.
If you have a idea to catch this kind of net exception and identify which code cause the problem , let me know your experiences.