Bug Javascript can fatally error without re-enabling GUI buttons

Irrat

Member
Description

When an error is thrown by javascript that contains a newline, I sometimes found that despite the script no longer running, I cannot interact with mafia's GUI.
The buttons are grayed out as if a script is in use.

The issue appears to be here, which simply means that if the output contains a new line, mafia should not update the display state. So if the last line that's printed is one that contains a new line, the panels enabled states are not updated.

Reproduce Steps

Run mafia
Enter into CLI
jsq cliExecute("js {}"); throw JSON.parse(`"\\n"`)

You will notice that the buttons are grayed out, even though the script has finished with no other scripts in use.

1672181834571.png1672181844559.png

This can also be reproduced as a standalone script.js with the following:
Code:
require("kolmafia").cliExecute("js {}");
throw "error";

What I expect to happen


The buttons to be usable

What happens

The buttons are unusable and I must press escape which triggers a new display message which does not contain a newline, and thus can restore functionality.

Notes

I wasn't able to reproduce this in ash, and didn't think it was worth the effort to find a method.
 
Top