aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workers/network.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-11-10 08:48:49 +0000
committerMohamed Bassem <me@mbassem.com>2025-11-10 08:48:49 +0000
commitd0f71a4c9e8e3a4ce56b486e429d3e455f67f07b (patch)
treee48fe4965ab5e24fd2c3b90f4d14bf69b912ce2d /apps/workers/network.ts
parent4cf0856e39c4d69037a6c1a4c3a2a7f803b364a7 (diff)
downloadkarakeep-d0f71a4c9e8e3a4ce56b486e429d3e455f67f07b.tar.zst
fix: fix crash in crawler on invalid URL in matchesNoProxy
Diffstat (limited to 'apps/workers/network.ts')
-rw-r--r--apps/workers/network.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/workers/network.ts b/apps/workers/network.ts
index acfd2439..d1cda62c 100644
--- a/apps/workers/network.ts
+++ b/apps/workers/network.ts
@@ -7,6 +7,7 @@ import { LRUCache } from "lru-cache";
import fetch, { Headers } from "node-fetch";
import serverConfig from "@karakeep/shared/config";
+import logger from "@karakeep/shared/logger";
const DISALLOWED_IP_RANGES = new Set([
// IPv4 ranges
@@ -212,9 +213,14 @@ export function getRandomProxy(proxyList: string[]): string {
}
export function matchesNoProxy(url: string, noProxy: string[]) {
- const urlObj = new URL(url);
- const hostname = urlObj.hostname;
- return hostnameMatchesAnyPattern(hostname, noProxy);
+ try {
+ const urlObj = new URL(url);
+ const hostname = urlObj.hostname;
+ return hostnameMatchesAnyPattern(hostname, noProxy);
+ } catch (e) {
+ logger.error(`Failed to parse URL: ${url}: ${e}`);
+ return false;
+ }
}
export function getProxyAgent(url: string) {