From 401049de5a2f073ca4676476cb99f2c37035f803 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Sun, 10 May 2026 06:09:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0GPC=E7=BB=93=E8=B4=A6?= =?UTF-8?q?=E9=87=8D=E5=90=AF=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81=E6=97=A0=E8=BF=9B=E5=B1=95?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 8 +++++--- tests/auto-run-step6-restart.test.js | 30 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index efa7aa6..48b997e 100644 --- a/background.js +++ b/background.js @@ -7748,14 +7748,16 @@ function isGpcTaskEndedFailure(error) { } function isGpcCheckoutRestartRequiredFailure(error) { + const rawMessage = String(typeof error === 'string' ? error : error?.message || ''); const message = getErrorMessage(error); - if (/PLUS_CHECKOUT_NON_FREE_TRIAL::|今日应付金额不是\s*0|没有免费试用资格/i.test(message)) { + const combinedMessage = `${rawMessage}\n${message}`; + if (/PLUS_CHECKOUT_NON_FREE_TRIAL::|今日应付金额不是\s*0|没有免费试用资格/i.test(combinedMessage)) { return false; } - if (/GPC_TASK_ENDED::/i.test(message)) { + if (/GPC_TASK_ENDED::/i.test(rawMessage)) { return true; } - return /GPC\s*API\s*请求超时|步骤\s*[67][\s\S]*GPC[\s\S]*(?:任务轮询超时|请求超时|超时|timeout|timed\s*out|卡死|无响应)|account\s+already\s+linked|GOPAY已经绑了订阅|(?:账号|账户|GoPay|GOPAY)[\s\S]*(?:已绑定|已经绑定|已绑|绑了订阅|绑定了订阅)|创建\s*GPC\s*订单失败[\s\S]*(?:任务已结束|任务结束|failed|expired|discarded|请求超时|timeout|timed\s*out)/i.test(message); + return /GPC\s*API\s*请求超时|GPC\s*任务状态超过\s*\d+\s*秒无进展|GPC[\s\S]*请重新创建任务|步骤\s*[67][\s\S]*GPC[\s\S]*(?:任务轮询超时|请求超时|超时|timeout|timed\s*out|卡死|无响应)|account\s+already\s+linked|GOPAY已经绑了订阅|(?:账号|账户|GoPay|GOPAY)[\s\S]*(?:已绑定|已经绑定|已绑|绑了订阅|绑定了订阅)|创建\s*GPC\s*订单失败[\s\S]*(?:任务已结束|任务结束|failed|expired|discarded|请求超时|timeout|timed\s*out)/i.test(message); } function isGoPayCheckoutRestartRequiredFailure(error) { diff --git a/tests/auto-run-step6-restart.test.js b/tests/auto-run-step6-restart.test.js index 1210f2e..480db22 100644 --- a/tests/auto-run-step6-restart.test.js +++ b/tests/auto-run-step6-restart.test.js @@ -399,6 +399,36 @@ test('auto-run treats GPC account binding as recoverable step 6 restart', async assert.deepStrictEqual(events.invalidations.map((entry) => entry.step), [5]); }); +test('auto-run restarts GPC checkout from step 6 when task status has no progress', async () => { + const plusGpcSteps = { + 6: { key: 'plus-checkout-create' }, + 7: { key: 'plus-checkout-billing' }, + 10: { key: 'oauth-login' }, + 11: { key: 'fetch-login-code' }, + 12: { key: 'confirm-oauth' }, + 13: { key: 'platform-verify' }, + }; + const harness = createHarness({ + startStep: 6, + failureStep: 7, + failureBudget: 1, + failureMessage: 'GPC_TASK_ENDED::GPC 任务状态超过 60 秒无进展(已创建),请重新创建任务。', + stepDefinitions: plusGpcSteps, + finalOAuthChainStartStep: 10, + customState: { + stepStatuses: { 3: 'completed' }, + plusPaymentMethod: 'gpc-helper', + plusCheckoutSource: 'gpc-helper', + }, + }); + + const events = await harness.run(); + + assert.deepStrictEqual(events.steps, [6, 7, 6, 7, 10, 11, 12, 13]); + assert.deepStrictEqual(events.invalidations.map((entry) => entry.step), [5]); + assert.ok(events.logs.some(({ message }) => /回到步骤 6 重新创建 GPC 任务/.test(message))); +}); + test('auto-run does not restart GPC checkout when Plus account has no free-trial eligibility', async () => { const plusGpcSteps = { 6: { key: 'plus-checkout-create' },