Skip to content

Commit 100f8f9

Browse files
fix(tlon): add request timeout to media downloads and image uploads
1 parent 05d1728 commit 100f8f9

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎extensions/tlon/src/monitor/media.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coer
1414
const MAX_IMAGES_PER_MESSAGE = 8;
1515
const TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS = 30_000;
1616

17+
/** Overall request timeout for remote media fetches that are idle before any data. */
18+
const TLON_MEDIA_DOWNLOAD_TIMEOUT_MS = 120_000;
19+
1720
interface ExtractedImage {
1821
url: string;
1922
alt?: string;
@@ -70,6 +73,7 @@ export async function downloadMedia(
7073
const fetchOptions = {
7174
url,
7275
maxBytes: MAX_IMAGE_BYTES,
76+
timeoutMs: TLON_MEDIA_DOWNLOAD_TIMEOUT_MS,
7377
readIdleTimeoutMs: TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS,
7478
ssrfPolicy: undefined,
7579
requestInit: { method: "GET" },

‎extensions/tlon/src/urbit/upload.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { uploadFile } from "../tlon-api.js";
66

77
const TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS = 30_000;
88

9+
/** Overall request timeout for image upload fetches that are idle before any data. */
10+
const TLON_UPLOAD_IMAGE_TIMEOUT_MS = 120_000;
11+
912
/**
1013
* Fetch an image from a URL and upload it to Tlon storage.
1114
* Returns the uploaded URL, or falls back to the original URL on error.
@@ -24,6 +27,7 @@ export async function uploadImageFromUrl(imageUrl: string): Promise<string> {
2427
const fetched = await readRemoteMediaBuffer({
2528
url: imageUrl,
2629
maxBytes: MAX_IMAGE_BYTES,
30+
timeoutMs: TLON_UPLOAD_IMAGE_TIMEOUT_MS,
2731
readIdleTimeoutMs: TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS,
2832
ssrfPolicy: undefined,
2933
requestInit: { method: "GET" },

0 commit comments

Comments
 (0)