From f2589ad47c5f51ce7eb8414d57715d4a0b722a82 Mon Sep 17 00:00:00 2001 From: Autumn-27 <53844290+Autumn-27@users.noreply.github.com> Date: Mon, 14 Sep 2026 09:37:08 -0400 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E4=BF=AE=E5=A4=8D=20demo=20?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=AF=A6=E6=83=85=E9=A1=B5=E6=97=81=E8=B7=AF?= =?UTF-8?q?=E6=8F=90=E9=97=AE=E5=8E=86=E5=8F=B2=E7=BC=BA=E5=A4=B1=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=95=B4=E9=A1=B5=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mock 模式下 GET /api/tasks//side-questions 无路由,被读兜底当集合返回 [],data.items 为 undefined,旁路 hook 的 merge() 迭代抛 TypeError: t is not iterable,异常在 setState updater 中经 render 重抛、catch 接不住,整页被错误 边界接管。mock handler 显式返回空旁路历史,sideAPI.history 同时归一化返回值。 --- CHANGELOG.md | Bin 52827 -> 53586 bytes web/src/lib/mock/handler.ts | 7 +++++++ web/src/lib/side-questions.ts | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7df7732ad3b816407f30b7a8f50a9f3055c65cd..e1bcfab93d7b2bbccde4def342287e0267d9a1c7 100644 GIT binary patch delta 752 zcmY*X%Wl&^6kQ;Gf(=(<0YswNBZS1FLfs)$2_b|uZag$mlQ^}VMOSfOd9=<0nzU)+ zv~_7wD%3bFeI&8td;uG_>>AJ5UgZ~zA~0!A^2u}3w4CNhu z_Y9M)You49YVJnSSc%wcj(H3cxaJmV+a&+Puct{Vd!sbGL7CK3drmJ6=)*_GuM)%Z zG8ce&PUfZ}GLA_IoK6o=GS1^qkvQhZsEJAl3&H}pwKYI7EY9O6PZ1EKOV+Qv!Kq_@ zr5klXvr7p)EsBEp9At<{5Es}bW09MSVm7Mo8L4Apt&mQK6hFJ=eWEo1Nm!nlaF3@a z6HE2?=Th?7HM z#5#_hPTuJk$2;5x%ciCL@~&qXp51jTDnqy}omOr4s0Yly*)Y?b;N~%egk+SDKb9dX za6I#FsI0h!_E_%!xm0cTGj5IDb5D9q|HQ1nVXA1H`l~lHQ*5#(path: string, method = "GET", body?: unknown): Promise } export const sideAPI = { - history: (parent: string, before = 0) => request(`${parent}/side-questions?before=${before}`), + // 历史必须归一化后再交给调用方:items 一旦不是数组,消费端的 setState updater 会抛, + // 而 React 会把 updater 的异常推迟到 render 阶段重抛 —— 那时调用方的 catch 已经够不着, + // 整页直接被错误边界接管。 + history: async (parent: string, before = 0) => { + const data = await request>(`${parent}/side-questions?before=${before}`); + return { + items: Array.isArray(data?.items) ? data.items : [], + current: data?.current ?? null, + next_cursor: Number(data?.next_cursor) || 0, + snapshot: data?.snapshot ?? null, + } satisfies SideHistory; + }, ask: (parent: string, question: string, client_request_id: string) => request(`${parent}/side-questions`, "POST", { question, client_request_id }), clear: (parent: string) => request(`${parent}/side-questions`, "DELETE"),