• js.on_exit script not being called(?) under certain circumstances

    From echicken@1:103/705 to GitLab issue in main/sbbs on Thu Aug 15 19:38:22 2024
    open https://gitlab.synchro.net/main/sbbs/-/issues/777

    Bit of a weird one, and fair warning that the script in question is ugly and just shy of 10K lines. It's transpiled from TypeScript and "bundled" (has a bunch of dependencies inlined).

    In [exec/fido-nodelist-browser.js](exec/fido-nodelist-browser.js) I use `js.on_exit` to revert console attributes, bbs.sys_status, etc. to what they were when the script started, as one does.

    On lines 2 through 8 of the file you'll see several calls to `js.on_exit`. These ones work, and were manually inserted by myself.

    On lines 9246 through 9252 you'll see the same calls, but these are way down at the end of the script, inside a function, and inside an IIFE inside an IIFE. These ones do not work (ie. when lines 2 - 8 are absent/commented out).

    I tried moving the working series of calls (lines 2 - 8) into a function inside an IIFE inside an IIFE and calling it within that same closure, and they still worked, so this closure/nesting doesn't seem to be the issue.

    I tried removing all of the latter calls involving string concatenation (eg. `js.on_exit("bbs.sys_status ".concat(bbs2.sys_status, ";"));`) in case this string `concat` method was broken, or `bbs2` was undefined or inaccessible. Made no difference. I tried substituting all of these `js.on_exit` calls with just one: `js.on_exit('console.pause();');`, and there was no pause.

    Reviewing the script, I don't see anything overwriting `js` or `js.on_exit` at any point. I see no errors in my log when the script exits. I can't see anything in the JS itself that would be causing this.
    --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to GitLab note in main/sbbs on Thu Aug 15 19:40:48 2024
    https://gitlab.synchro.net/main/sbbs/-/issues/777#note_5530

    (And no, I don't intend to dump a bunch of these monster scripts into `exec`; this was a special case of wanting to replace a crappy old module that was barely usable.)
    --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)