fix: Do not automatically retry failed document import request
This commit is contained in:
@@ -640,7 +640,9 @@ export default class DocumentsStore extends Store<Document> {
|
|||||||
formData.append(info.key, info.value);
|
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");
|
invariant(res?.data, "Data should be available");
|
||||||
this.addPolicies(res.policies);
|
this.addPolicies(res.policies);
|
||||||
return this.add(res.data);
|
return this.add(res.data);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type Options = {
|
|||||||
|
|
||||||
interface FetchOptions {
|
interface FetchOptions {
|
||||||
download?: boolean;
|
download?: boolean;
|
||||||
|
retry?: boolean;
|
||||||
credentials?: "omit" | "same-origin" | "include";
|
credentials?: "omit" | "same-origin" | "include";
|
||||||
headers?: Record<string, string>;
|
headers?: Record<string, string>;
|
||||||
}
|
}
|
||||||
@@ -99,14 +100,17 @@ class ApiClient {
|
|||||||
let response;
|
let response;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await fetchWithRetry(urlToFetch, {
|
response = await (options?.retry === false ? fetch : fetchWithRetry)(
|
||||||
method,
|
urlToFetch,
|
||||||
body,
|
{
|
||||||
headers,
|
method,
|
||||||
redirect: "follow",
|
body,
|
||||||
credentials: "same-origin",
|
headers,
|
||||||
cache: "no-cache",
|
redirect: "follow",
|
||||||
});
|
credentials: "same-origin",
|
||||||
|
cache: "no-cache",
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (window.navigator.onLine) {
|
if (window.navigator.onLine) {
|
||||||
throw new NetworkError("A network error occurred, try again?");
|
throw new NetworkError("A network error occurred, try again?");
|
||||||
|
|||||||
Reference in New Issue
Block a user