diff --git a/src/components/Root/FFetch.js b/src/components/Root/FFetch.js index 0b10068d..658139dc 100644 --- a/src/components/Root/FFetch.js +++ b/src/components/Root/FFetch.js @@ -65,6 +65,7 @@ import { RTR_AT_TTL_FRACTION, RTR_ERROR_EVENT, RTR_FLS_TIMEOUT_EVENT, + RTR_TIME_MARGIN_IN_MS, RTR_FLS_WARNING_EVENT, RTR_RT_EXPIRY_IF_UNKNOWN, } from './constants'; @@ -142,7 +143,7 @@ export class FFetch { this.store.dispatch(setRtrFlsTimeout(setTimeout(() => { this.logger.log('rtr-fls', 'emitting RTR_FLS_TIMEOUT_EVENT'); window.dispatchEvent(new Event(RTR_FLS_TIMEOUT_EVENT)); - }, rtTimeoutInterval))); + }, rtTimeoutInterval - RTR_TIME_MARGIN_IN_MS))); // Calling /logout a small margin before cookie is deleted to ensure it is included in the request }); }; diff --git a/src/components/Root/constants.js b/src/components/Root/constants.js index 1ec4b562..d5d991e7 100644 --- a/src/components/Root/constants.js +++ b/src/components/Root/constants.js @@ -87,3 +87,9 @@ export const RTR_IDLE_MODAL_TTL = '1m'; */ export const RTR_AT_EXPIRY_IF_UNKNOWN = '10s'; export const RTR_RT_EXPIRY_IF_UNKNOWN = '10m'; + +/** + * To account for minor delays between events (such as cookie expiration and API calls), + * this is a small amount of time to wait so the proper order can be ensured if they happen simultaneously. + */ +export const RTR_TIME_MARGIN_IN_MS = 200; \ No newline at end of file