fix: 修复 Node.js 环境下请求超时参数非法的问题

This commit is contained in:
xream committed 2026-08-30 18:49:43 +08:00
1 parent be8cba9f7d
commit ebfcc8ca14
3 files changed
+14 -10

No files matched your search

+1 -1
View File
@@ -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",
+12 -4
View File
@@ -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 () {
+1 -5
View File
@@ -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')");