From 038744fe4025b522062023fc1433242921084ede Mon Sep 17 00:00:00 2001 From: baiqing Date: Fri, 22 May 2026 22:00:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(marketplace):=20=E7=99=BB=E5=BD=95=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=86=99=20prefs=20=E5=A4=B1=E8=B4=A5=E6=97=B6?= =?UTF-8?q?=E8=A1=A5=E5=9B=9E=20.catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构 OAuth 登录为 GithubLoginModal 后,onLoginSuccess / MarketplaceSection onSuccess 用裸 void updatePrefs(...) 写 marketplaceDevLogin,丢掉了重构前 try/catch 里的失败日志 —— prefs 写入失败会冒成未处理的 promise rejection。 补回 .catch + console.warn,与重构前行为一致。 --- openless-all/app/src/pages/Marketplace.tsx | 5 ++++- openless-all/app/src/pages/settings/MarketplaceSection.tsx | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openless-all/app/src/pages/Marketplace.tsx b/openless-all/app/src/pages/Marketplace.tsx index a2220b12..398e2b64 100644 --- a/openless-all/app/src/pages/Marketplace.tsx +++ b/openless-all/app/src/pages/Marketplace.tsx @@ -396,7 +396,10 @@ export function Marketplace() { // GitHub 登录成功 → 写回 prefs.marketplaceDevLogin,让后续 X-Dev-User 走真实身份。 const onLoginSuccess = useCallback((nextLogin: string) => { - void updatePrefs(current => ({ ...current, marketplaceDevLogin: nextLogin })); + // prefs 写入失败只 console 记一笔(与重构前的 OAuth 轮询一致)—— 不能裸 void, + // 否则 reject 会冒成未处理的 promise rejection。 + void updatePrefs(current => ({ ...current, marketplaceDevLogin: nextLogin })) + .catch(e => console.warn('[marketplace] save login to prefs failed', e)); setActionMsg({ kind: 'ok', text: t('marketplace.oauth.successAs', { login: nextLogin }) }); }, [updatePrefs, t]); diff --git a/openless-all/app/src/pages/settings/MarketplaceSection.tsx b/openless-all/app/src/pages/settings/MarketplaceSection.tsx index 9268d0be..bd21a932 100644 --- a/openless-all/app/src/pages/settings/MarketplaceSection.tsx +++ b/openless-all/app/src/pages/settings/MarketplaceSection.tsx @@ -98,7 +98,8 @@ export function MarketplaceSection() { setShowLogin(false)} onSuccess={nextLogin => { - void savePrefs(current => ({ ...current, marketplaceDevLogin: nextLogin })); + void savePrefs(current => ({ ...current, marketplaceDevLogin: nextLogin })) + .catch(e => console.warn('[marketplace] save login to prefs failed', e)); }} /> )}