Socket instances don't seem to use the attached 'error' listener on error:
>s = net.connect({host: 'xxx', port: 1883}, print)
>s.on('error', (e)=>print('EEE',e))
>s.end()
>s
=Socket: { type: 0,
"#onconnect": function () { [native code] },
opt: {
host: "neptune",
port: 1883 },
conn: false,
"#onerror": function (e) { ... },
clsNow: true, cls: true, endd: true }
>s.write('x')
Uncaught Error: This socket is closed.
at line 1 col 12
s.write('x')
^
Is this expected behaviour?
I'm asking because in NodeJS, when an error listener is attached, no exception is thrown but the listener called (with the exception message) instead. If Espruino did the same, the last line should read like this: EEE Error: This socket is closed. ... (EEE because the listener prints it, then the error.)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Socket instances don't seem to use the attached 'error' listener on error:
Is this expected behaviour?
I'm asking because in NodeJS, when an error listener is attached, no exception is thrown but the listener called (with the exception message) instead. If Espruino did the same, the last line should read like this:
EEE Error: This socket is closed. ...
(EEE because the listener prints it, then the error.)