zmuxuny opened a new pull request, #7118:
URL: https://github.com/apache/rocketmq-dashboard/pull/7118
### Which Issue(s) This PR Fixes
Fixes #7116
### Brief Description
A logout followed by login is an SPA navigation, so the module-level
instance-list coalescing map survives it. A newly mounted page can join a
still-pending list request from the previous login instead of requesting the
current inventory. It then receives that old result or failure, including when
the same user signs back in.
Bind the coalescing map to the authentication-store snapshot. Login/logout
replace that snapshot; ordinary page renders do not. Keep existing
query/data-mode keys, same-session request sharing, defensive result copies,
mutation invalidation, and promise-identity cleanup. Already issued calls are
not cancelled or rewritten.
This isolates frontend requests across login boundaries. It does not change
backend authorization or claim that shared instance inventory is private to an
individual user. No dependency or UI text changes.
### How Did You Test This Change?
Four regressions fail on unchanged production: same-user/different-user
login crossed with old request success/failure. The API is called once instead
of twice, and the current caller receives the old result/error. The tests use
the real auth-store login/logout methods and controlled API promises.
Two additional controls ensure concurrent same-session callers still share
one fresh request, and an old success or failure cannot remove that newer
request from the coalescing map. Existing tests also retain Mock/Real
separation, defensive copies, and write-triggered invalidation.
From `web/`:
```sh
npx vitest run src/services/instanceService.test.ts --pool=threads
--maxWorkers=1
# 21 tests passed
npx vitest run src/services src/stores/authStore.test.ts
src/stores/authStorage.test.ts \
src/api/instance.test.ts src/hooks/useInstanceFilter.test.tsx \
src/components/__tests__/InstanceSelect.test.tsx \
src/pages/instance/__tests__/InstancePage.test.tsx
src/layouts/MainLayout.test.tsx \
src/pages/login/index.test.tsx src/App.test.tsx --pool=threads
--maxWorkers=1
# 22 files, 226 tests passed
npx tsc -b --force
npx eslint src/services/instanceService.ts
src/services/instanceService.test.ts
npx prettier --check src/services/instanceService.ts
src/services/instanceService.test.ts
git diff --check
```
Fail-before command:
```sh
npx vitest run src/services/instanceService.test.ts --pool=threads
--maxWorkers=1 \
-t startsAFreshListRequestAfterLoginTest
# 4 failed, with the expected API-call-count and wrong-result/error
assertions
```
### 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 strings or source files
- [x] Independent production and test diff review completed
- [ ] Backend architecture suite (`mvn test`), not run for this
frontend-only change
AI assistance was used to investigate the request-sharing boundary,
implement and review the fix and tests, and execute verification. No live
cluster was contacted.
--
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]