Skip to content

scripts/uninstall.js: malformed settings.json crashes script mid-cleanup, leaving state partially deleted #434

Description

@nanaubusiness

In scripts/uninstall.js lines 38-40:

} catch (e) {
  if (e.code !== 'ENOENT') throw e;
}

If settings.json contains malformed JSON, JSON.parse throws a SyntaxError. SyntaxError has no .code property, so e.code !== 'ENOENT' is true and the error is re-thrown — crashing the script mid-cleanup.

At that point, .ponytail-active and config.json have already been deleted by removeIfExists() calls on lines 21-22, but settings.json may have been partially modified (if the crash happened after the delete settings.statusLine write on line 35 but before the script crashed).

Fix: catch SyntaxError specifically, or check e.code === undefined && !(e instanceof SyntaxError — actually the cleanest fix is to wrap the JSON.parse in its own try/catch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions