From d0f71a4c9e8e3a4ce56b486e429d3e455f67f07b Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Mon, 10 Nov 2025 08:48:49 +0000 Subject: fix: fix crash in crawler on invalid URL in matchesNoProxy --- apps/workers/network.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apps/workers') 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) { -- cgit v1.2.3-70-g09d2