• docs/v322_new.md exec/load/ircd/core.js src/sbbs3/js_console.cpp js_in

    From Rob Swindell (on Windows 11)@VERT to Git commit to main/sbbs/master on Sun Oct 25 13:37:51 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/3109381166a8f58a85d97ab2
    Modified Files:
    docs/v322_new.md exec/load/ircd/core.js src/sbbs3/js_console.cpp js_internal.cpp js_socket.cpp js_socket.h sbbs.h
    Log Message:
    js: report asynchronous connect failures and keep callbacks alive

    Socket.connect() with a callback ran the resolve and connect on a thread
    and sent the result over a socket pair that the callback engine never
    read: it set is_connected the moment the thread started and invoked the callback regardless. A refused connect, or a hostname that did not
    resolve (that path sent nothing at all), reached the callback looking
    connected with no peer address. The IRC daemon then sent its server
    handshake into dead links to unreachable hubs and, since outbound
    connects are serialized, delayed its reconnect to a reachable one.

    The thread now reports {error, gai} on every path and the engine reads it before the callback, setting is_connected, error and error_str. The
    socket is not marked connected while the connect is pending.

    Every stored event callback (js.setTimeout/setInterval/setImmediate/ addEventListener, Socket.on/once/connect, console.on/once) was a bare JSFunction* with no GC root, and JS_ValueToFunction() returns the shared function behind a closure, dropping its scope. A callback that captured
    a variable crashed in the interpreter when invoked. Store and root the
    function object that was passed, and call it with JS_CallFunctionValue().

    Windows select() was given a negative timeval when no timer was pending
    and empty descriptor sets when only timers were pending, so connect-only scripts exited with "Timeout with no event" and timer-only scripts with
    "poll() returned with error 22". Pass NULL for an infinite wait and sleep
    when there is nothing to select on.

    All three date from the callback engine's introduction in 1928973941 (2021-04-02) and 06ec7d4148 (2021-04-13). The ircd's connect-failure
    notice now includes the error text.

    Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net