zmuxuny opened a new pull request, #7102: URL: https://github.com/apache/rocketmq-dashboard/pull/7102
### Which Issue(s) This PR Fixes Fixes #7097 ### Brief Description Logout and login use SPA navigation, so a request from the previous login can still return 401 after a new session is established. The shared Axios client and both AI streaming fetch paths used to clear that new session and navigate to `/login`. - Advance a page-local session revision on every login/logout, including signing back in as the same user. - Capture request ownership in an Axios-config WeakMap and before each AI send/attach fetch. Only a 401 belonging to the current revision clears the session and redirects. - Preserve the original rejected request/stream error for obsolete requests. Current-session 401 handling and the existing public-auth exemptions remain covered. The revision is memory-only and scoped to one SPA lifetime. This does not change cookies, credentials, storage keys, backend authorization, or cross-tab session coordination. ### How Did You Test This Change? Before the production change, the four delayed-401 regressions failed: both Axios relogin cases (same/different user), AI send, and AI attach invoked the login redirect for an obsolete request. The three current-session 401 controls passed. From `web/`: ```sh npx vitest run src/api/client.test.ts src/api/ai.test.ts src/stores/authStorage.test.ts src/stores/authStore.test.ts --pool=threads --maxWorkers=1 # 4 files, 68 tests passed npx vitest run src/api src/stores src/App.test.tsx src/pages/login src/layouts/MainLayout.test.tsx src/layouts/MainLayout.navigation.test.tsx --pool=threads --maxWorkers=1 # 38 files, 313 tests passed npx tsc -b npx eslint src/api/ai.ts src/api/ai.test.ts src/api/client.ts src/api/client.test.ts src/stores/authStorage.ts src/stores/authStorage.test.ts npx prettier --check src/api/ai.ts src/api/ai.test.ts src/api/client.ts src/api/client.test.ts src/stores/authStorage.ts src/stores/authStorage.test.ts ``` All commands passed; `git diff --check` passed. The regression tests also assert that obsolete requests still reject with 401, no hard navigation occurs, the new identity remains stored, and storage failure does not prevent ownership invalidation. No backend suite or live deployment was exercised locally. ### Checklist - [x] One coherent change; unrelated modifications are not bundled in - [x] Commit subject follows Conventional Commits - [x] Added regression tests use `...Test` names - [x] No new UI text or source files; existing ASF headers retained - [x] Independent diff review completed - [ ] Backend architecture suite (`mvn test`), not run for this frontend-only change AI assistance was used to investigate the request lifecycle, implement the guard and regressions, review the diff, and execute the checks. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
