mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-28 07:24:12 +00:00
fix: 修复 Node.js 环境下请求超时参数非法的问题
This commit is contained in:
3 files changed
+14
-10
No files matched your search
@@ -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
@@ -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 () {
|
||||
|
||||
Vendored
+1
-5
@@ -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')");
|
||||
|
||||
Reference in new issue
Block a user