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')");