Skip to content

Commit cda71b4

Browse files
committed
Fixes #1888 (hopefully): disables timeout on writeFile requests
These can be large and take longer than 30s.
1 parent 2337f23 commit cda71b4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

client/spaces/http_space_primitives.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ export class HttpSpacePrimitives implements SpacePrimitives {
6868
if (isWebKit) {
6969
url = encodeExtensionDot(url);
7070
}
71-
options.signal = AbortSignal.timeout(fetchTimeout);
71+
if (fetchTimeout > 0) {
72+
options.signal = AbortSignal.timeout(fetchTimeout);
73+
}
7274
options.redirect = "manual";
7375
const result = await fetch(url, options);
7476
if (result.status >= 500 && result.status < 600) {
@@ -129,6 +131,12 @@ export class HttpSpacePrimitives implements SpacePrimitives {
129131
}
130132
return result;
131133
} catch (e: any) {
134+
// AbortSignal.timeout() throws a DOMException with name "TimeoutError".
135+
// This is NOT an offline condition — the network may be fine, just slow.
136+
if (e.name === "TimeoutError") {
137+
console.warn("Request timed out for", url);
138+
throw new Error(`Request timed out after ${fetchTimeout}ms`);
139+
}
132140
// Errors when there is no internet connection:
133141
//
134142
// * Firefox: NetworkError when attempting to fetch resource (with SW and without)
@@ -218,6 +226,7 @@ export class HttpSpacePrimitives implements SpacePrimitives {
218226
// Casting to any due to TypeScript fetch type limitations
219227
body: data as any,
220228
},
229+
0, // No timeout for uploads — transfer time depends on file size and connection speed
221230
);
222231
return headersToFileMeta(path, res.headers)!;
223232
}

0 commit comments

Comments
 (0)