forked from pinks/eris
1
0
Fork 0
This commit is contained in:
pinks 2023-09-15 00:40:12 +02:00
parent 9155d513b5
commit 8e81f82d8b
1 changed files with 3 additions and 1 deletions

View File

@ -32,13 +32,15 @@ bot.api.config.use(async (prev, method, payload, signal) => {
let timedOut = false;
const timeout = setTimeout(() => {
timedOut = true;
// TODO: this sometimes throws with "can't abort a locked stream" and crashes whole process
controller.abort();
}, 30 * 1000);
signal?.addEventListener("abort", () => {
controller.abort();
});
try {
return await prev(method, payload, controller.signal);
const result = await prev(method, payload, controller.signal);
return result;
} finally {
clearTimeout(timeout);
if (timedOut) {