Skip to content

Commit

Permalink
Added a small time margin to wait so that cookie is not deleted befor…
Browse files Browse the repository at this point in the history
…e /logout request
  • Loading branch information
ryandberger committed Aug 7, 2024
1 parent c25e068 commit b8d1fd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Root/FFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
});
};

Expand Down
6 changes: 6 additions & 0 deletions src/components/Root/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 95 in src/components/Root/constants.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Newline required at end of file but not found

Check failure on line 95 in src/components/Root/constants.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Newline required at end of file but not found

0 comments on commit b8d1fd8

Please sign in to comment.