Skip to content

Commit 8346132

Browse files
committed
perf: force gc after download
1 parent dd81417 commit 8346132

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

js/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import TelegramBot from "node-telegram-bot-api";
2+
import { Readable, type Stream } from "stream";
23
import { z } from "zod";
3-
import { Readable } from "node:stream";
44

55
// https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#file-options-metadata
66
process.env.NTBA_FIX_350 = "false";
@@ -184,7 +184,7 @@ class Bot {
184184
}
185185
): Promise<void> {
186186
const downloadUrl = cobaltResult.url;
187-
let downloadFrom: string | Readable = downloadUrl;
187+
let downloadFrom: string | Stream = downloadUrl;
188188
let contentType: string | undefined;
189189
if (downloadUrl.includes("cdninstagram.com")) {
190190
// proxy instead because Telegram blocks instagram.com domains
@@ -224,6 +224,8 @@ class Bot {
224224
}
225225
console.error(`Error al enviar el video ${downloadUrl}:`, e);
226226
throw e;
227+
} finally {
228+
Bun.gc(true);
227229
}
228230
}
229231
}

0 commit comments

Comments
 (0)