zjncs opened a new pull request, #5608:
URL: https://github.com/apache/rocketmq-dashboard/pull/5608

   Closes #5607
   
   ## Problem
   
   The repo has an established convention for paginated lists — when a page 
query returns `items.length === 0 && total > 0 && page > 1`, the page is reset 
to the last valid page and re-queried (alerts.tsx:375-381 documents it as 
deliberate policy, "matching the audit page's clamp"). Eight pages implement 
it: alerts, audit, acl, UserManagement, topic, consumer, 
settings/DataSourceTab, settings/CloudCredentialTab.
   
   `notificationDeliveries.tsx` was the sole paginated ops list without it. 
Delivered records are cleaned up server-side, so the result set shrinks under 
the user — anyone on page 2+ when that happens got a **permanently empty 
table** while the pagination still showed the old total, and the view never 
self-recovered.
   
   ## Fix
   
   Apply the identical clamp in the load effect's `.then`, before storing the 
result:
   
   ```ts
   if (result.items.length === 0 && result.total > 0 && page > 1) {
       const lastPage = Math.max(1, Math.ceil(result.total / pageSize));
       if (lastPage < page) {
           setPage(lastPage);
           return;
       }
   }
   ```
   
   ## Verification
   
   - New `NotificationDeliveriesClamp.test.tsx` (deterministic, no timers): 
first load returns 21 items/total 21, click page 2, page-2 response returns 
`{items: [], total: 5}` — **FAILS on master** (no clamp refetch: `expected last 
call to have been called with [ObjectContaining {"page": 1}]`), **PASSES with 
this change**
   - Regression: existing `NotificationDeliveriesPage.test.tsx` 4/4 — full file 
pair 5/5 green
   - Mutation check: reverting the clamp makes the new test fail again; 
restoring it passes
   
   ## Collision note
   
   The file is touched by 7 open PRs; none adds a clamp. The nearest hunks 
(#5048/#5337/#5495) modify the adjacent `.catch` of the same effect and are all 
based on the diverged `rocketmq-studio` integration branch (already needing a 
rebase in this file); this change is confined to the `.then` body. The clamp 
bug also exists on the `rocketmq-studio` version of the file, so the finding 
survives that branch.


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