Loyal-Young opened a new pull request, #6420:
URL: https://github.com/apache/rocketmq-dashboard/pull/6420

   ### Which Issue(s) This PR Fixes
   
   Fixes #6412
   
   ### Brief Description
   
   `useVisiblePolling` queues each callback in a promise microtask. Clearing 
the interval does not cancel a callback already queued by a timer or visibility 
event, so the old callback can still send a request after unmount, disabling 
polling, replacing the callback, or hiding the page.
   
   Check the effect's lifetime and current visibility immediately before 
invoking the queued callback. Keep the shared in-flight guard so requests 
already in progress still prevent overlapping polls after an effect changes.
   
   ### How Did You Test This Change?
   
   From `web`:
   
   - `node node_modules/vitest/vitest.mjs run 
src/hooks/useVisiblePolling.test.tsx --pool=threads --maxWorkers=1`: 9 tests 
passed. The four new queued-callback regressions failed before the fix.
   - ESLint and Prettier on both changed files: passed.
   - `node node_modules/typescript/bin/tsc -p tsconfig.app.json --noEmit 
--pretty false --composite false --incremental false`: passed.
   - `git diff --check`: passed.
   
   The tests also verify that polling resumes with the current callback and 
preserve coverage of in-flight overlap and rejected requests. No browser 
end-to-end test was run. Backend architecture checks are not affected.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits
   - [x] Regression tests added, new test names end in `Test`
   - [x] No new UI text, source files, or backend architecture changes
   - [x] No user-facing configuration or documented API changes
   
   ### AI Assistance
   
   AI assistance was used to trace the promise/effect lifecycle, draft the fix 
and regression tests, and run local checks. The verification results above 
describe the checks actually executed.
   


-- 
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]

Reply via email to