node-json-socket icon indicating copy to clipboard operation
node-json-socket copied to clipboard

handling the exception that may occur when writing on socket

Open rolancia opened this issue 5 years ago • 1 comments

Hi Sir,

i faced an error when writing on socket with multi users.

i had checked out below you used 'https://github.com/nodejs/node/blob/master/lib/net.js'

it calls 'emit('close', ...) after already closed, so assumed your '_closed' value might be not synchronized.

Thank you Rolancia

rolancia avatar Jan 15 '20 01:01 rolancia

if users didn't put error handler, the process will be terminated when exception occurs while calling _socket.write in 'sendMessage' due to the default error handler kills the process with exit code 1.

i thought the user using this library may not want to face the exception. it might happen very rarely but it will happen someday. example, i had encountered that everyday.

i think the throwing code i put can prevent that (in the beginning i put a code defining default handler but it could be bad

rolancia avatar Jan 16 '20 05:01 rolancia