js.on_exit script not being called(?) under certain circumstances
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 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.