fix(ipintelligence): apply configured timeout to MMDB downloads and expose IP intelligence timeout option

This commit is contained in:
2026-05-21 01:42:48 +00:00
parent 23df951023
commit 8a4f756fef
4 changed files with 56 additions and 9 deletions
+14 -7
View File
@@ -522,14 +522,21 @@ export class IpIntelligence {
* Fetch a URL and return the response as a Buffer
*/
private async fetchBuffer(url: string): Promise<Buffer> {
const response = await fetch(url, {
headers: { 'User-Agent': '@push.rocks/smartnetwork' },
});
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: HTTP ${response.status}`);
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
try {
const response = await fetch(url, {
signal: controller.signal,
headers: { 'User-Agent': '@push.rocks/smartnetwork' },
});
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: HTTP ${response.status}`);
}
const arrayBuffer = await response.arrayBuffer();
return Buffer.from(arrayBuffer);
} finally {
clearTimeout(timeoutId);
}
const arrayBuffer = await response.arrayBuffer();
return Buffer.from(arrayBuffer);
}
/**