Skip to content

Fix session timeout warning#1576

Merged
olexii4 merged 3 commits into
mainfrom
fix_session_timeout_warning
May 28, 2026
Merged

Fix session timeout warning#1576
olexii4 merged 3 commits into
mainfrom
fix_session_timeout_warning

Conversation

@olexii4
Copy link
Copy Markdown
Contributor

@olexii4 olexii4 commented May 19, 2026

What does this PR do?

Fixes several bugs in the session-timeout warning modal (#1557) and adds silent
auto-extend for active users so they never experience unexpected sign-outs.


Bug 1 — Wrong selector fallback

selectSessionTimeout used ?? 86400 — if the backend omits sessionTimeout,
the modal activated with a 24 h timeout instead of staying disabled.
Changed to ?? -1.

Bug 2 — JS idle timer vs OAuth cookie mismatch

The hook reset the idle timer on UI events (mousemove, keydown, …) but the
OAuth cookie is refreshed by HTTP requests through the gateway (including
background workspace polling). Added an Axios response interceptor that calls
startIdleTimer() on every successful response, keeping both clocks in sync.

Bug 3 — No guard for very short sessions

Added MIN_SESSION_TIMEOUT_SECONDS = 90. The modal is suppressed for sessions
shorter than 90 s (< 30 s of warning time — not useful).

Bug 4 — Broken keep-alive URL

KEEP_ALIVE_URL was set to /dashboard/api/server-config, which always returns 200, is a
lightweight read, and passes through the OAuth proxy (which refreshes the session
cookie on the request).### Screenshot/screencast of this PR

What issues does this PR fix or reference?

Is it tested? How?

  1. Deploy Eclipse Che with the dashboard image from this PR.
  2. Apply the next patch
kubectl patch checluster/eclipse-che -n eclipse-che --type=merge \
  -p '{"spec":{"networking":{"auth":{"gateway":{"oAuthProxy":{"cookieExpireSeconds":120}}}}}}'
  1. Idle path: open dashboard, do not move the mouse.
    Modal appears at 60 s; sign-out at 120 s.
  2. Active path: keep moving the mouse.
    No modal; session silently extended every time idle exceeds 45 s.

Release Notes

Docs PR

olexii4 added 2 commits May 19, 2026 18:10
Three bugs in the session-timeout warning introduced by #1557:

1. selectSessionTimeout selector used ?? 86400 as fallback — if the
   backend omits sessionTimeout (old operator), the modal activated with
   a spurious 24 h timeout instead of staying disabled. Changed to ?? -1
   so the modal only activates when the backend explicitly provides a
   positive value.

2. The idle timer reset on UI events (mousemove/click/keydown) but not
   on authenticated HTTP requests. The OAuth proxy refreshes the session
   cookie on every request (including background workspace polling), so
   the JS clock diverged from the real session expiry. Added an Axios
   response interceptor that resets the idle timer on each successful
   response, keeping both clocks in sync.

3. Sessions shorter than 90 s leave less than 30 s of usable warning
   time (WARNING_LEAD_SECONDS = 60). Added a MIN_SESSION_TIMEOUT_SECONDS
   = 90 guard that suppresses the modal for such short timeouts.

Assisted-by: Claude Sonnet 4.5
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Users reported session expiry while actively using the dashboard
(mousemove, keydown, click). Activity events reset the JS idle timer
but do NOT refresh the actual OAuth cookie — so sessions could silently
expire on pages with no background API requests (e.g. GitConfig tab).

Add a throttled keep-alive mechanism in the activity handler:

- Compute keepAliveThresholdMs = max(30, (sessionTimeout-60)/2)*1000.
  For a 120 s session this is 30 s; for a 24 h session ~12 h.
- On every activity event, capture elapsed time since the last idle-
  timer reset, then synchronously restart the JS idle timer.
- If elapsed >= threshold, ALSO fire a silent GET /dashboard/api/user/id.
  The OAuth proxy refreshes the session cookie on this request and the
  Axios response interceptor resets the idle timer from that point.

Result: active users on pages with no polling never see unexpected
sign-outs; the warning modal only appears for truly idle sessions.

Also add MIN_SESSION_TIMEOUT_SECONDS = 90 guard to suppress the modal
for sessions that are too short to show a meaningful warning.

Assisted-by: Claude Sonnet 4.5
Signed-off-by: Oleksii Orel <oorel@redhat.com>
@olexii4 olexii4 requested review from akurinnoy and ibuziuk as code owners May 19, 2026 18:20
@che-bot
Copy link
Copy Markdown
Contributor

che-bot commented May 19, 2026

Click here to review and test in web IDE: Contribute

@olexii4 olexii4 requested a review from svor May 19, 2026 18:21
- /dashboard/api/user/id does not exist in the dashboard backend (404);
  the Axios success interceptor never fired so keep-alive was a no-op.
- Split keep-alive into backgroundPing (silent, no Redux dispatch) and
  pingKeepAlive (explicit extend via onExtend, dispatches
  serverConfigReceiveAction to keep sessionTimeout in sync). Avoids
  unexpected config-driven UI changes mid-session from background pings.
- isPingingRef guard prevents concurrent background pings from rapid
  activity events near the threshold.
- Move the response interceptor from the default axios instance to
  getAxiosInstance() — all dashboard API calls use the shared instance.
- Move AUTO_EXTEND_BUFFER_SECONDS to module-level constant.
- MIN_SESSION_TIMEOUT_SECONDS = 90 ensures keepAliveThresholdMs is
  always positive.
- Log keep-alive errors with console.warn instead of silencing them.
- Interceptor is installed only when sessionTimeout >= 90 s (disabled
  sessions skip the useEffect body entirely).
- 3 new tests: interceptor-not-installed-when-disabled, concurrent-ping
  guard, background-ping uses fetchServerConfig.

Assisted-by: Claude Sonnet 4.5
Signed-off-by: Oleksii Orel <oorel@redhat.com>
@olexii4 olexii4 force-pushed the fix_session_timeout_warning branch from 9f62345 to 36fb786 Compare May 19, 2026 18:33
@github-actions
Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1576 (linux/amd64, linux/arm64)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1576", name: che-dashboard}]}}]"

1 similar comment
@github-actions
Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1576 (linux/amd64, linux/arm64)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1576", name: che-dashboard}]}}]"

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 19, 2026

@olexii4: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v19-e2e-puppeteer 36fb786 link true /test v19-e2e-puppeteer

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@svor
Copy link
Copy Markdown
Contributor

svor commented May 20, 2026

@SkorikSergey please take a look

Copy link
Copy Markdown
Contributor

@SkorikSergey SkorikSergey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to merge.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 28, 2026

@SkorikSergey: changing LGTM is restricted to collaborators

Details

In response to this:

Looks good to merge.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

@svor svor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: olexii4, SkorikSergey, svor

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@olexii4 olexii4 merged commit 543afab into main May 28, 2026
21 of 23 checks passed
@olexii4 olexii4 deleted the fix_session_timeout_warning branch May 28, 2026 11:15
artaleks9 pushed a commit that referenced this pull request May 29, 2026
Three bugs in the session-timeout warning introduced by #1557:

1. selectSessionTimeout selector used ?? 86400 as fallback — if the
   backend omits sessionTimeout (old operator), the modal activated with
   a spurious 24 h timeout instead of staying disabled. Changed to ?? -1
   so the modal only activates when the backend explicitly provides a
   positive value.

2. The idle timer reset on UI events (mousemove/click/keydown) but not
   on authenticated HTTP requests. The OAuth proxy refreshes the session
   cookie on every request (including background workspace polling), so
   the JS clock diverged from the real session expiry. Added an Axios
   response interceptor that resets the idle timer on each successful
   response, keeping both clocks in sync.

3. Sessions shorter than 90 s leave less than 30 s of usable warning
   time (WARNING_LEAD_SECONDS = 60). Added a MIN_SESSION_TIMEOUT_SECONDS
   = 90 guard that suppresses the modal for such short timeouts.

Assisted-by: Claude Sonnet 4.5
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants