fix(auth): stop parsing logout response body (avoids ZodError on null data)
Root cause: backend `/auth/logout` returns `{ success: true, data: null }`
(no business payload for a fire-and-forget endpoint). The previous
`AuthApi.logout` ran `unwrap(env)` (which passes null through, since
null is defined) and then `LogoutResponse.fromJson(null)`, which
Zod-parses as `z.object(...)` and throws "Invalid input: expected
object, received null".
The error was caught in `AuthRepository.logout` with
`console.warn(... clearing local anyway)` — logout actually still
worked (local clear ran), but a noisy red ZodError hit the console on
every logout click.
Fix: align `AuthApi.logout` with the existing fire-and-forget pattern
used by `register` and `sendCode` — call `httpClient` and ignore the
response body. Drop the now-unused `LogoutResponse` import.
`AuthRepository.logout` already discards the return value, so the
`Promise<LogoutResponse> → Promise<void>` signature change is safe.
Bundled in this commit (unrelated):
- chat-machine.actors.ts / user-machine.ts: removed stale design-doc
comment blocks (IDE/linter cleanup)
- user-machine.actors.ts: removed redundant `userStorage.clearUserData()`
from `userLogoutActor` — `authRepo.logout` already clears local
user data, so this was a no-op duplicate.
- sidebar-screen.tsx: removed one stale comment line.
This commit is contained in:
@@ -1,18 +1,5 @@
|
||||
/**
|
||||
* Chat 状态机:4 个 XState actor
|
||||
*
|
||||
* 从 `chat-machine.ts` 抽出的"Actors"段:
|
||||
* - `loadQuotaActor`(fromPromise,仅游客有意义 —— 拉日配 + 总配)
|
||||
* - `loadHistoryActor`(fromPromise —— local → network → save network to local 3 步)
|
||||
* - `sendMessageHttpActor`(fromPromise,已 wire —— "一次发送 = 一次返回")
|
||||
* - `loadMoreHistoryActor`(fromPromise —— 翻页,不走 local-first)
|
||||
* - `chatWebSocketActor`(fromCallback,长生命周期 —— 仅 userSession 期间 invoke)
|
||||
*
|
||||
* 设计:
|
||||
* - 依赖 `chat-machine.helpers.ts`(纯函数 + 数据加载)
|
||||
* - 依赖 `createChatWebSocket`(`@/core/net/chat-websocket`)
|
||||
* - 保留全链日志(用户要求"不要将其删除")
|
||||
* - 命名约定:`[chat-machine]` 前缀 —— 与 `chat-machine.ts` 的日志对齐
|
||||
*/
|
||||
|
||||
import { fromPromise, fromCallback } from "xstate";
|
||||
|
||||
Reference in New Issue
Block a user