From ebfcc8ca1404ad42d0994a29a2fa867aaa894985 Mon Sep 17 00:00:00 2001 From: xream Date: Sun, 30 Aug 2026 18:49:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Node.js=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=E8=AF=B7=E6=B1=82=E8=B6=85=E6=97=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=9D=9E=E6=B3=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/test/vendor/open-api.spec.js | 16 ++++++++++++---- backend/src/vendor/open-api.js | 6 +----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/backend/package.json b/backend/package.json index 8053a514..e2fc505d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.36.53", + "version": "2.36.54", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "packageManager": "pnpm@11.0.9", diff --git a/backend/src/test/vendor/open-api.spec.js b/backend/src/test/vendor/open-api.spec.js index 4e9961be..8b77212a 100644 --- a/backend/src/test/vendor/open-api.spec.js +++ b/backend/src/test/vendor/open-api.spec.js @@ -117,10 +117,18 @@ describe('open-api HTTP adapter', function () { }); expect(agentOptions).to.have.length(2); - expect(agentOptions.map(({ proxyTunnel }) => proxyTunnel)).to.deep.equal([ - true, - true, - ]); + expect( + agentOptions.map(({ proxyTunnel }) => proxyTunnel), + ).to.deep.equal([true, true]); + }); + + it('normalizes numeric string timeouts for undici', async function () { + await HTTP({ timeout: '5000' }).get('https://example.com/subscription'); + + expect(agentOptions[0]).to.include({ + bodyTimeout: 5000, + headersTimeout: 5000, + }); }); it('uses the Undici option that throws at the redirect limit', async function () { diff --git a/backend/src/vendor/open-api.js b/backend/src/vendor/open-api.js index ba1723b2..d30b0e78 100644 --- a/backend/src/vendor/open-api.js +++ b/backend/src/vendor/open-api.js @@ -481,11 +481,7 @@ export function HTTP(defaultOptions = { baseURL: '' }) { const opts = JSON.parse(JSON.stringify(options)); opts.body = body; - opts.timeout = opts.timeout || 8000; - - if (isNaN(opts.timeout)) { - opts.timeout = 8000; - } + opts.timeout = Number(opts.timeout) || 8000; if (isNode) { const undici = eval("require('undici')");