fix: wrap rehash updateProfile in try/catch for best-effort (#54)
All checks were successful
PR Check / rust (push) Successful in 16m33s
PR Check / frontend (push) Successful in 2m14s
PR Check / rust (pull_request) Successful in 16m33s
PR Check / frontend (pull_request) Successful in 2m15s

Both handlePinSuccess handlers (ProfileSwitcher and ProfileSelectionPage)
now catch updateProfile errors so that a failed rehash persistence does
not block switchProfile.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
escouade-bot 2026-04-09 08:01:08 -04:00 committed by le king fu
parent 2f610bf10a
commit e5be6f5a56
2 changed files with 10 additions and 2 deletions

View file

@ -39,7 +39,11 @@ export default function ProfileSwitcher() {
const handlePinSuccess = async (rehashed?: string | null) => { const handlePinSuccess = async (rehashed?: string | null) => {
if (pinProfile) { if (pinProfile) {
if (rehashed) { if (rehashed) {
await updateProfile(pinProfile.id, { pin_hash: rehashed }); try {
await updateProfile(pinProfile.id, { pin_hash: rehashed });
} catch {
// Best-effort rehash: don't block profile switch if persistence fails
}
} }
switchProfile(pinProfile.id); switchProfile(pinProfile.id);
setPinProfile(null); setPinProfile(null);

View file

@ -26,7 +26,11 @@ export default function ProfileSelectionPage() {
const handlePinSuccess = async (rehashed?: string | null) => { const handlePinSuccess = async (rehashed?: string | null) => {
if (pinProfileId) { if (pinProfileId) {
if (rehashed) { if (rehashed) {
await updateProfile(pinProfileId, { pin_hash: rehashed }); try {
await updateProfile(pinProfileId, { pin_hash: rehashed });
} catch {
// Best-effort rehash: don't block profile switch if persistence fails
}
} }
switchProfile(pinProfileId); switchProfile(pinProfileId);
setPinProfileId(null); setPinProfileId(null);