Skip to content

Commit c40f08b

Browse files
committed
refactor(tlon): share media fetch timeout policy
1 parent 5fa7102 commit c40f08b

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Header wait and body progress are separate failure modes. Keep both Tlon
2+
// media directions on one policy so attachment and upload fallbacks stay aligned.
3+
export const TLON_MEDIA_FETCH_TIMEOUTS = {
4+
responseHeaderTimeoutMs: 120_000,
5+
readIdleTimeoutMs: 30_000,
6+
} as const;

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import {
1010
saveRemoteMedia,
1111
} from "openclaw/plugin-sdk/media-runtime";
1212
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
13+
import { TLON_MEDIA_FETCH_TIMEOUTS } from "../media-fetch-timeouts.js";
1314

1415
const MAX_IMAGES_PER_MESSAGE = 8;
15-
const TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS = 30_000;
16-
const TLON_MEDIA_RESPONSE_HEADER_TIMEOUT_MS = 120_000;
1716

1817
interface ExtractedImage {
1918
url: string;
@@ -71,8 +70,7 @@ export async function downloadMedia(
7170
const fetchOptions = {
7271
url,
7372
maxBytes: MAX_IMAGE_BYTES,
74-
responseHeaderTimeoutMs: TLON_MEDIA_RESPONSE_HEADER_TIMEOUT_MS,
75-
readIdleTimeoutMs: TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS,
73+
...TLON_MEDIA_FETCH_TIMEOUTS,
7674
ssrfPolicy: undefined,
7775
requestInit: { method: "GET" },
7876
};

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
* Upload an image from a URL to Tlon storage.
33
*/
44
import { MAX_IMAGE_BYTES, readRemoteMediaBuffer } from "openclaw/plugin-sdk/media-runtime";
5+
import { TLON_MEDIA_FETCH_TIMEOUTS } from "../media-fetch-timeouts.js";
56
import { uploadFile } from "../tlon-api.js";
67

7-
const TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS = 30_000;
8-
const TLON_UPLOAD_IMAGE_RESPONSE_HEADER_TIMEOUT_MS = 120_000;
9-
108
/**
119
* Fetch an image from a URL and upload it to Tlon storage.
1210
* Returns the uploaded URL, or falls back to the original URL on error.
@@ -25,8 +23,7 @@ export async function uploadImageFromUrl(imageUrl: string): Promise<string> {
2523
const fetched = await readRemoteMediaBuffer({
2624
url: imageUrl,
2725
maxBytes: MAX_IMAGE_BYTES,
28-
responseHeaderTimeoutMs: TLON_UPLOAD_IMAGE_RESPONSE_HEADER_TIMEOUT_MS,
29-
readIdleTimeoutMs: TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS,
26+
...TLON_MEDIA_FETCH_TIMEOUTS,
3027
ssrfPolicy: undefined,
3128
requestInit: { method: "GET" },
3229
});

0 commit comments

Comments
 (0)