Skip to content

Commit 6fee490

Browse files
fix(frontend): don't let a failed settings reload escape as a rejection
When a write fails, save() reloads the user so the screen stops showing a value the server rejected. That reload was unguarded, so if it failed too — the usual case, since the server that refused the write is often still down — the rejection escaped save(). Every caller but savePreferredName invokes it as `void save(...)`, where that surfaces as an unhandled promise rejection rather than as anything the user can see. The failure is now contained and the original write error left on screen: it is the actionable one, and the value shown is the one the user typed anyway.
1 parent 14964b7 commit 6fee490

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

frontend/src/views/SettingsView.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,18 @@ async function save(type: UserSettingType, value: unknown, note: string): Promis
6767
error.value = message(err);
6868
// The server rejected the write, so the local value no longer reflects what is
6969
// stored. Reload rather than leaving a stale value on screen.
70-
const user = await auth.load(true);
71-
if (user) {
72-
settings.value = user.settings;
73-
initialName.value = user.settings.preferredName;
70+
try {
71+
const user = await auth.load(true);
72+
if (user) {
73+
settings.value = user.settings;
74+
initialName.value = user.settings.preferredName;
75+
}
76+
} catch {
77+
// The reload failed too, so the screen keeps the value the user typed. Leave
78+
// the write error showing — it is the actionable one — and do not let this
79+
// escape: most callers invoke save() as `void save(...)`, where a rejection
80+
// surfaces as an unhandled promise rejection rather than as anything a user
81+
// can see.
7482
}
7583
}
7684
}

0 commit comments

Comments
 (0)