fix(fetch): bump tenant generation only when the access token changes (MAPPS-187) #176

Merged
vas2000-work merged 2 commits from fix/MAPPS-187-double-fetch into main 2026-06-16 01:25:01 +02:00
Owner

What

Fix the mount-time double-fetch of list resources. set_access_token bumped TENANT_GENERATION on every call, and startup sets the same token twice (OIDC callback, then rehydration / complete_login). Every use_resource that reads active_tenant_generation() (timesheets, time-entries, and other list pages) therefore ran twice on mount.

Change

set_access_token now bumps the generation only when the token actually changes:

  • org switch / refresh -> different token -> bump -> resources refetch (unchanged behavior),
  • redundant re-set of the identical token (startup rehydration) -> no bump -> no duplicate fetch.

Safe by construction: the only behavior change is skipping a refetch when the token did not change, which was wasted work.

Scope / verification notes

  • This addresses the generation-keyed list resources (the bulk of the issue).
  • The UpdateBanner /version check keys on the auth context, not the generation, so its duplicate may need a separate follow-up (noted on the issue).
  • The AC is a per-page request count; that needs a runtime network-panel check on staging once this is deployed. The change compiles clean (fmt + clippy + cargo check --target wasm32-unknown-unknown).

Testing

  • cargo fmt --all --check, cargo clippy --all-targets -- -D warnings, cargo check --target wasm32-unknown-unknown: all clean (rust-builder container).
## What Fix the mount-time double-fetch of list resources. `set_access_token` bumped `TENANT_GENERATION` on every call, and startup sets the same token twice (OIDC callback, then rehydration / `complete_login`). Every `use_resource` that reads `active_tenant_generation()` (timesheets, time-entries, and other list pages) therefore ran twice on mount. ## Change `set_access_token` now bumps the generation only when the token actually changes: - org switch / refresh -> different token -> bump -> resources refetch (unchanged behavior), - redundant re-set of the identical token (startup rehydration) -> no bump -> no duplicate fetch. Safe by construction: the only behavior change is skipping a refetch when the token did not change, which was wasted work. ## Scope / verification notes - This addresses the generation-keyed list resources (the bulk of the issue). - The `UpdateBanner` `/version` check keys on the auth context, not the generation, so its duplicate may need a separate follow-up (noted on the issue). - The AC is a per-page request count; that needs a runtime network-panel check on staging once this is deployed. The change compiles clean (fmt + clippy + `cargo check --target wasm32-unknown-unknown`). ## Testing - `cargo fmt --all --check`, `cargo clippy --all-targets -- -D warnings`, `cargo check --target wasm32-unknown-unknown`: all clean (rust-builder container).
fix(fetch): bump tenant generation only when the access token changes (MAPPS-187)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m42s
5fadac7184
set_access_token bumped TENANT_GENERATION on every call. Startup sets the same token twice (the OIDC callback, then rehydration / complete_login), so the unconditional bump made every active_tenant_generation-subscribed resource fetch twice on mount (timesheets, time-entries, and other list pages). Bump only when the token actually changes: an org switch or refresh still produces a different token and refetches, while a redundant re-set of the identical token no longer does.

The UpdateBanner /version check keys on the auth context (not the tenant generation), so its duplicate fetch may need a separate follow-up; full per-page request-count verification (the AC) is a runtime network-panel check on staging once deployed.

#MAPPS-187

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merge branch 'main' into fix/MAPPS-187-double-fetch
All checks were successful
Create release / Create release from merged PR (pull_request) Has been skipped
Check / clippy + fmt + tests (pull_request) Successful in 1m4s
54931e8731
vas2000-work deleted branch fix/MAPPS-187-double-fetch 2026-06-16 01:25:01 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!176
No description provided.