Node.js套接字_writableState是未定义的?

我有一些代码应该closures套接字,但是会导致一个错误:(使用NODE_DEBUG = net)

NET: 5482 onread undefined 32 7 39 NET: 5482 got data NET: 5482 _read ATL 0 // these are output from the program 3 ATL net.js:425 if (this._writableState.finished) ^ TypeError: Cannot read property 'finished' of undefined at Socket.destroySoon (net.js:425:26) at Socket.<anonymous> (/home/crunch/js_relay_tools/atprox.js:45:4) at Socket.EventEmitter.emit (events.js:117:20) at Socket.<anonymous> (_stream_readable.js:746:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable_ (_stream_readable.js:408:10) at emitReadable (_stream_readable.js:404:5) at readableAddChunk (_stream_readable.js:165:9) at Socket.Readable.push (_stream_readable.js:127:10) at TCP.onread (net.js:526:21) 

这个套接字存储在一个数组中,但我不认为它应该有所作为。 我已经尝试了Socket.end(我现在正在使用)和Socket.destroySoon,但都没有工作,并且有类似的错误(都处理可写状态的套接字未定义)。

结束码:

 var sx = sa[parseInt(b[0])]; // get socket from array var cf = sx==undefined?function (){sock.write("#E,no such socket")}:(sx.close || sx.end || function () {}); // get close/end function cf(); // call close function sa[parseInt(b[0])] = undefined; // clear array entry so socket cannot be closed again 

更让人感兴趣的是,我在脚本的另一个地方有类似的代码,它工作正常,使用相同的数组。 我已经确认套接字实际上是打开的并且能够发送和接收数据,但是不能closures。

TL; DR:Socket._writableState是未定义的,但是我仍然可以读写套接字,并且不能closures/结束它

这是一个错误,还是我搞砸了?