forked from FoundKeyGang/FoundKey
server: use AbortSignal.timeout
Using AbortSignal.timeout is a cleaner solution that using an AbortController and triggering it ourselves with setTimeout.
This commit is contained in:
parent
b94aeb2df2
commit
6fd422f2b0
1 changed files with 1 additions and 6 deletions
|
@ -49,11 +49,6 @@ export async function getResponse(_args: {
|
||||||
..._args,
|
..._args,
|
||||||
};
|
};
|
||||||
|
|
||||||
const controller = new AbortController();
|
|
||||||
setTimeout(() => {
|
|
||||||
controller.abort();
|
|
||||||
}, args.timeout);
|
|
||||||
|
|
||||||
const res = await fetch(args.url, {
|
const res = await fetch(args.url, {
|
||||||
method: args.method,
|
method: args.method,
|
||||||
headers: Object.assign({
|
headers: Object.assign({
|
||||||
|
@ -63,7 +58,7 @@ export async function getResponse(_args: {
|
||||||
redirect: args.redirect,
|
redirect: args.redirect,
|
||||||
size: args.size,
|
size: args.size,
|
||||||
agent: getAgentByUrl,
|
agent: getAgentByUrl,
|
||||||
signal: controller.signal,
|
signal: AbortSignal.timeout(args.timeout),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in a new issue