Skip to content

Commit 427f28c

Browse files
committed
Reset rules at startup if persisted data is invalid
This should never happen, since it means we persisted data we can't load again, but if it does happen somehow (a very buggy release that breaks compatibility) this ensures that users see a clear error, and have their rule data reset, instead of their app breaking inexplicably and indefinitely, requiring a full reinstall.
1 parent ead0f23 commit 427f28c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/model/rules/rules-store.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ export class RulesStore {
207207
rules: migrateRuleData(data.rules)
208208
}),
209209
customArgs: { rulesStore: this } as DeserializationArgs
210+
}).catch((err) => {
211+
console.log('Failed to load last-run rules',
212+
err,
213+
// Log the full rule data for debugging:
214+
JSON.parse(localStorage.getItem('rules-store') ?? '{}')?.rules
215+
);
216+
217+
reportError(err);
218+
alert(`Could not load rules from last run.\n\n${err}`);
219+
// We then continue, which resets the rules exactly as if this was the user's first run.
210220
});
211221

212222
if (!this.rules) {

0 commit comments

Comments
 (0)