screepers / screeps-multimeter

The most useful tool on your screeps workbench.
MIT License
89 stars 28 forks source link

App crashes when logging "<==" in console #40

Closed tomekbielaszewski closed 4 years ago

tomekbielaszewski commented 4 years ago

Multimeter crashes when I log my creep state changes. My logs for standard state changes looks like this:

[21897200] creep[Builder:21896981]: idle-state ==> refilling-state
[21897200] creep[Builder:21897008]: refilling-state ==> repairing-state
[21897200] creep[Builder:21897008]: repairing-state ==> idle-state
[21897200] creep[Builder:21897008]: idle-state ==> refilling-state

but when this logs is printed in console it crashes:

[21897201] creep[Harvester:21895835]: storing-state <== moving-state

with error: Parse Error: <== moving-state

SystemParadox commented 4 years ago

It tries to parse colours from HTML tags like the screeps console does, but we need to be smarter about text like this.

tomekbielaszewski commented 4 years ago

I've just debugged the app and it appears it crashes on this line: event.line = parseLogJson(html2json(event.line)); in plugins/html.js

that's html2json function which is causing an issue here

SystemParadox commented 4 years ago

I've replaced the ancient parser with something more sensible but it turns out that doesn't always handle this case very well either! It doesn't error, but the <== text is lost. I may end up writing my own to fix this.

SystemParadox commented 4 years ago

I've replaced htmlparser2 with parse5, which seems to be much more lenient. Can you give this a try and let me know if you encounter any other issues? Thanks!

SystemParadox commented 4 years ago

Published in 1.11.1.