From 5880af465e09347973df9c21675ddb304edd5e62 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Wed, 14 Oct 2026 10:37:26 +0800 Subject: [PATCH] =?UTF-8?q?check-catalog=E3=80=81check-catalog-loop?= =?UTF-8?q?=EF=BC=9A=E5=85=B3=E9=A1=B5=E9=9D=A2=E4=B9=8B=E5=89=8D=E5=85=88?= =?UTF-8?q?=E6=92=A4=E6=8E=89=E6=8B=A6=E6=88=AA=E3=80=81=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E8=BF=98=E5=9C=A8=E8=B7=AF=E4=B8=8A=E7=9A=84=E9=82=A3=E5=87=A0?= =?UTF-8?q?=E6=9D=A1=EF=BC=8C=E5=8F=96=E7=9C=9F=E5=AE=9E=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=8B=A6=E6=88=AA=E5=9C=A8=E9=A1=B5=E9=9D=A2=E5=85=B3?= =?UTF-8?q?=E6=8E=89=E4=B9=8B=E5=90=8E=E6=89=8D=E5=9B=9E=E6=9D=A5=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=8A=8A=E6=A3=80=E6=9F=A5=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=B8=A6=E5=B4=A9=EF=BC=88=E6=BB=A1=E8=B4=9F=E8=8D=B7=E5=B9=B6?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E5=81=B6=E5=8F=91=E3=80=8CRequest=20context?= =?UTF-8?q?=20disposed=E3=80=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check-catalog-loop.mjs | 8 +++++++- scripts/check-catalog.mjs | 14 +++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/check-catalog-loop.mjs b/scripts/check-catalog-loop.mjs index 5e127644..909e2d9e 100644 --- a/scripts/check-catalog-loop.mjs +++ b/scripts/check-catalog-loop.mjs @@ -96,7 +96,13 @@ async function open(path, { handlers = [], viewport = { width: 1440, height: 900 await page.goto(`${WEB}${path}`, { waitUntil: 'networkidle' }) await page.evaluate((t) => document.documentElement.setAttribute('data-theme', t), THEME) await page.waitForTimeout(400) - return { page, sent, errors, natives, close: () => { opened.delete(ctx); return ctx.close() } } + // 关之前先撤掉拦截、忽略还在路上的那几条:满负荷并行时,取真实返回的拦截可能在页面关掉之后才回来, + // 没人接住的报错会把整个检查进程带崩(「Request context disposed」) + return { page, sent, errors, natives, close: async () => { + opened.delete(ctx) + await page.unrouteAll({ behavior: 'ignoreErrors' }).catch(() => {}) + return ctx.close() + } } } const goto = async (page, path) => { await page.goto(`${WEB}${path}`, { waitUntil: 'networkidle' }) diff --git a/scripts/check-catalog.mjs b/scripts/check-catalog.mjs index 371a0eb0..2e762729 100644 --- a/scripts/check-catalog.mjs +++ b/scripts/check-catalog.mjs @@ -105,7 +105,13 @@ async function open(path, { handlers = [], viewport = { width: 1440, height: 900 await page.goto(`${WEB}${path}`, { waitUntil: 'networkidle' }) await page.evaluate((t) => document.documentElement.setAttribute('data-theme', t), THEME) await page.waitForTimeout(400) - return { page, sent, errors, natives, close: () => { opened.delete(ctx); return ctx.close() } } + // 关之前先撤掉拦截、忽略还在路上的那几条:满负荷并行时,取真实返回的拦截可能在页面关掉之后才回来, + // 没人接住的报错会把整个检查进程带崩(「Request context disposed」) + return { page, sent, errors, natives, close: async () => { + opened.delete(ctx) + await page.unrouteAll({ behavior: 'ignoreErrors' }).catch(() => {}) + return ctx.close() + } } } const goto = async (page, path) => { await page.goto(`${WEB}${path}`, { waitUntil: 'networkidle' }) @@ -609,9 +615,11 @@ function jobHandlers(state, reply) { }], // 起草对话框写明用哪个起草模型:设置里的 catalog_draft(其余设置照真服务端的)、助手当前用的模型 [/^GET \/settings$/, async (route) => { - const real = await route.fetch() + // 页面已经关了(上一节收尾时还在路上):这一条不用再答 + const real = await route.fetch().catch(() => null) + if (!real) return route.abort().catch(() => {}) const body = await real.json().catch(() => ({})) - return route.fulfill({ response: real, json: { ...body, catalog_draft: state.draftModel } }) + return route.fulfill({ response: real, json: { ...body, catalog_draft: state.draftModel } }).catch(() => {}) }], [/^GET \/copilot\/model$/, (route) => json(state.assistantModel)(route)], ]