From 43e213a4231b91441e5ac0f934c3a6d89f475725 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Tue, 7 Jul 2026 20:59:15 +0000
Subject: [PATCH] Add explicit timeouts to external fetch calls
This commit adds `AbortSignal.timeout()` to the `fetch` calls in `network.ts`, `snap-market.ts`, and `sync-sources.mjs` to prevent server resource exhaustion caused by hanging external connections.
Co-authored-by: felirami <6752178+felirami@users.noreply.github.com>
---
.jules/sentinel.md | 4 ++++
package-lock.json | 2 +-
package.json | 2 +-
scripts/sync-sources.mjs | 3 +++
src/lib/network.ts | 1 +
src/lib/snap-market.ts | 2 ++
6 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/.jules/sentinel.md b/.jules/sentinel.md
index b5d9250..0341a81 100644
--- a/.jules/sentinel.md
+++ b/.jules/sentinel.md
@@ -12,3 +12,7 @@
**Vulnerability:** XSS risk via unsanitized `<` characters in `JSON.stringify` output injected into `` to break out of the context and inject malicious scripts.
**Prevention:** Always replace `<` with `\u003c` when injecting JSON output into script tags, e.g., `JSON.stringify(data).replace(/ {
headers: {
Accept: "application/json",
},
+ signal: AbortSignal.timeout(NODE_PROBE_TIMEOUT_MS),
});
if (!response.ok) {
diff --git a/src/lib/snap-market.ts b/src/lib/snap-market.ts
index 19b7c1a..3f87ae2 100644
--- a/src/lib/snap-market.ts
+++ b/src/lib/snap-market.ts
@@ -1,6 +1,7 @@
import { SNAP, correctedSnapFdv } from "@/lib/snap";
export const SNAP_MARKET_REVALIDATE = 30;
+const MARKET_DATA_TIMEOUT_MS = 10_000;
type DexPeriod = {
buys?: number;
@@ -79,6 +80,7 @@ export async function getSnapMarketData(): Promise {
"user-agent": "hypersnap.org market data checker",
},
next: { revalidate: SNAP_MARKET_REVALIDATE },
+ signal: AbortSignal.timeout(MARKET_DATA_TIMEOUT_MS),
});
if (!response.ok) {