Updated the calendar to improve opportunity display and navigation
This commit is contained in:
@@ -34,17 +34,27 @@ function createAuthTokenRelay({
|
||||
}
|
||||
|
||||
const requestEntry = createTokenRelayRequestEntry(xsrfTokenSource, refreshResult, name, url);
|
||||
const controller = environment.AbortController ? new environment.AbortController() : null;
|
||||
let timeoutId;
|
||||
const timeout = new Promise((_, reject) => {
|
||||
if (!environment.setTimeout) return;
|
||||
timeoutId = environment.setTimeout(() => {
|
||||
reject(new Error("Token relay timed out after 30 seconds. Please try again."));
|
||||
controller?.abort();
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const response = await Promise.race([fetch(url, {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
...(controller ? { signal: controller.signal } : {}),
|
||||
headers: {
|
||||
"x-xsrf-token": xsrfTokenSource.token
|
||||
}
|
||||
});
|
||||
}), timeout]);
|
||||
|
||||
const responseBody = await readResponseBodyForDebug(response);
|
||||
const responseBody = await Promise.race([readResponseBodyForDebug(response), timeout]);
|
||||
|
||||
if (!response.ok) {
|
||||
logRequestSuccess(requestEntry, response, responseBody);
|
||||
@@ -63,8 +73,9 @@ function createAuthTokenRelay({
|
||||
let responseData;
|
||||
|
||||
try {
|
||||
responseData = await response.json();
|
||||
responseData = await Promise.race([response.json(), timeout]);
|
||||
} catch (error) {
|
||||
if (controller?.signal.aborted) throw error;
|
||||
logRequestSuccess(requestEntry, response, responseBody);
|
||||
|
||||
if (!refreshAttempted) {
|
||||
@@ -109,6 +120,8 @@ function createAuthTokenRelay({
|
||||
} catch (error) {
|
||||
logRequestFailure(requestEntry, error.message || "Request failed.");
|
||||
throw error;
|
||||
} finally {
|
||||
if (timeoutId !== undefined) environment.clearTimeout?.(timeoutId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user