fix: Do not automatically retry failed document import request

This commit is contained in:
Tom Moor
2024-02-11 11:28:57 -05:00
parent 2d6a7ed244
commit de34f33058
2 changed files with 15 additions and 9 deletions

View File

@@ -640,7 +640,9 @@ export default class DocumentsStore extends Store<Document> {
formData.append(info.key, info.value);
}
});
const res = await client.post("/documents.import", formData);
const res = await client.post("/documents.import", formData, {
retry: false,
});
invariant(res?.data, "Data should be available");
this.addPolicies(res.policies);
return this.add(res.data);

View File

@@ -26,6 +26,7 @@ type Options = {
interface FetchOptions {
download?: boolean;
retry?: boolean;
credentials?: "omit" | "same-origin" | "include";
headers?: Record<string, string>;
}
@@ -99,14 +100,17 @@ class ApiClient {
let response;
try {
response = await fetchWithRetry(urlToFetch, {
method,
body,
headers,
redirect: "follow",
credentials: "same-origin",
cache: "no-cache",
});
response = await (options?.retry === false ? fetch : fetchWithRetry)(
urlToFetch,
{
method,
body,
headers,
redirect: "follow",
credentials: "same-origin",
cache: "no-cache",
}
);
} catch (err) {
if (window.navigator.onLine) {
throw new NetworkError("A network error occurred, try again?");