Skip to content

Commit fe254c5

Browse files
committed
tweak: increase image retry attempts and add cache-busting version parameter
1 parent cd69c91 commit fe254c5

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

packages/imagekit-editor-dev/src/components/RetryableImage.tsx

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ const baseUrl = (url?: string) => {
5555
export default function RetryableImage(props: RetryableImageProps) {
5656
const {
5757
src,
58-
maxRetries = 3,
59-
retryDelay = 1000,
58+
maxRetries = 10,
59+
retryDelay = 10000,
6060
onRetryExhausted,
6161
onRetry,
6262
nonRetryableStatusCodes = DEFAULT_NON_RETRYABLE,
@@ -113,23 +113,16 @@ export default function RetryableImage(props: RetryableImageProps) {
113113
{ ok: true } | { ok: false; status?: number; message: string }
114114
> => {
115115
try {
116-
// Prefer HEAD to avoid downloading body; fall back to GET if HEAD fails quickly
117-
let res: Response | null = null
118-
try {
119-
res = await fetch(String(src), {
120-
method: "HEAD",
121-
cache: "no-cache",
122-
signal,
123-
})
124-
} catch {
125-
// Some CDNs don't allow HEAD on images—fall back to GET
126-
res = await fetch(String(src), {
127-
method: "GET",
128-
cache: "no-cache",
129-
signal,
130-
})
131-
}
132-
if (res.status !== 200) {
116+
const url = new URL(String(src))
117+
118+
url.searchParams.set("ik-version", Date.now().toString())
119+
120+
const res = await fetch(url.toString(), {
121+
method: "GET",
122+
signal,
123+
})
124+
125+
if (!res.headers.get("content-type")?.includes("image")) {
133126
return {
134127
ok: false,
135128
status: res.status,

0 commit comments

Comments
 (0)