diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index bd902412564ceb..fd1294ec9764f9 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -22,41 +22,52 @@ const kCurrentWriteRequest = Symbol('kCurrentWriteRequest'); const kCurrentShutdownRequest = Symbol('kCurrentShutdownRequest'); const kPendingShutdownRequest = Symbol('kPendingShutdownRequest'); -function checkReusedHandle(self) { - let socket = self[owner_symbol]; +function isClosing() { + let socket = this[owner_symbol]; - if (socket.constructor.name === 'ReusedHandle') + if (socket.constructor.name === 'ReusedHandle') { socket = socket.handle; - - return socket; -} - -function isClosing() { - const socket = checkReusedHandle(this); + } return socket.isClosing(); } function onreadstart() { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.readStart(); } function onreadstop() { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.readStop(); } function onshutdown(req) { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.doShutdown(req); } function onwrite(req, bufs) { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.doWrite(req, bufs); }