Altinn / Altinn/app-frontend-react
KeepAlive endpoint is invoked to often
- Dominant language
- TypeScript
- Stars
- 21
- Forks
- 33
- Avg merge
- 6d 23h
- Merged PRs (30d)
- 3
Description
### Description of the bug
#### The Bug
Today we have implemented a solution where we use the built-in React Query `refetchInterval` to call the `keepAlive` endpoint while the window is active to ensure that the session is kept alive during the session. The issue with this is that the user can leave their browser with our application as the active tab, which makes our code call the `keepAlive` endpoint every 10 minutes regardless of whether the user is interacting with our app or not.
#### Possible Solution
Save the `lastUserInteraction` within the memory to know when the user last interacted with our website. Then we can use the `lastUserInteraction` state to enable/disable the React Query which is sending the keepAlive request to the backend.
### Steps To Reproduce
1. Login
2. Keep the window and tab active with our app
3. Let the computer stay overnight
4. You are still logged in and keepAlive has been triggered every 10 minutes since you left your computer.
### Additional Information
_No response_
Contributor guide
Research direction
Start by locating the React Query keepAlive request and its refetchInterval configuration in the frontend. Review how user interaction is tracked, then verify that keepAlive stops after inactivity while the session remains usable after renewed interaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- authentication, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100