lizhimins commented on PR #6420: URL: https://github.com/apache/rocketmq-dashboard/pull/6420#issuecomment-6190301808
Closing this one: Thanks — the patch itself is harmless and the four regressions are well built, but we don't think the symptom described in the PR body can actually occur in this app, so we're closing it as a bug fix. `pollWhenVisible` is only ever invoked from a `setInterval` callback or a `visibilitychange` listener, and each of those is its own browser task, so the queued microtask drains at the end of that same task. React 18 flushes passive-effect cleanup through the Scheduler (a MessageChannel macrotask), which always lands after that microtask; the repo has no `flushSync` call that could invert the order, and the hook has exactly one caller (`BrokerCluster.tsx:262`), whose `autoRefresh` toggle and route-away both commit in their own event task. The `hidden` half has the same problem: the early-out at `useVisiblePolling.ts:31` and the microtask run inside one task, so visibility cannot change in between. Your tests reproduce the ordering because RTL's `act`/`rerender`/`un mount` flush cleanup synchronously — a test-environment artifact rather than production timing. If you want to re-frame this as explicit hardening (the hook becoming safe under a future synchronous-flush caller) we're happy to look again; as written it fixes a race the scheduler already prevents. -- 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]
