Skip to content

Exclude notification poll from sliding the idle session timeout#343

Open
level09 wants to merge 1 commit into
mainfrom
worktree-session-poll-fix
Open

Exclude notification poll from sliding the idle session timeout#343
level09 wants to merge 1 commit into
mainfrom
worktree-session-poll-fix

Conversation

@level09
Copy link
Copy Markdown
Collaborator

@level09 level09 commented May 23, 2026

Problem

The session idle timeout (PERMANENT_SESSION_LIFETIME) never fires. The notification poller hits GET /admin/api/notifications every 60s, and with Flask-Session's default SESSION_REFRESH_EACH_REQUEST=True each request rewrites the Redis session TTL back to full lifetime. A user who leaves a tab open is never logged out.

Fix

Mark the automatic poll with an X-Silent-Poll header and override should_set_storage so requests carrying it don't refresh the session expiry (unless they actually modified the session). All other requests, including user actions in the notification drawer, still slide the session.

  • enferno/app.py — per-request opt-out in should_set_storage.
  • enferno/static/js/mixins/notification-mixin.js — only the interval-driven refetchNotifications sends the header; user-initiated loads do not.

Tests

tests/test_session_poll_refresh.py: silent poll leaves the TTL untouched; a normal request still refreshes it.

@level09 level09 requested a review from apodacaduron as a code owner May 23, 2026 11:07
@level09 level09 self-assigned this May 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75ed9082-98a2-4da9-aa56-12ec6d7d5a90

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-session-poll-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@apodacaduron apodacaduron left a comment

Choose a reason for hiding this comment

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

Works as intended, notifications endpoint no longer refreshes session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants