You are reading a single comment by @Steffen and its replies. Click here to read the full conversation.
  • 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))
    =Socket: { type: 0, 
      "#onconnect": function () { [native code] }, 
      opt: { 
        host: "neptune", 
        port: 1883 }, 
      conn: false, 
      "#onerror": function (e) { ... }, 
      clsNow: true, cls: true, endd: true }
    Uncaught Error: This socket is closed.
     at line 1 col 12

    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.)


Avatar for Steffen @Steffen started