mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5262] [Bug]: dynamic update client list #3687
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3687
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mitrios-hub on GitHub (Jun 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5262
Describe the bug
I noticed that since version 3.0, the data about connected clients does not update dynamically (or updates incorrectly or incompletely). For example, users are online, but not all are shown, or zero are shown; sorting works incorrectly — the most recently online may appear at the very beginning, and some at the very end of the list, and so on.
Go to another tab in the panel and return to the client list — it does not help. Only a page refresh works.
How to reproduce the problem
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.3.1
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Debian 13
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 13, 2026):
Both symptoms you describe — the list not reflecting newly connected clients and the sort order becoming stale — are caused by the same architectural gap in the v3 React frontend.
How the client list is currently updated
frontend/src/hooks/useClients.tsfetches the paged client list withstaleTime: Infinity(line 185). React Query therefore never schedules an automatic background refetch; the page is only re-fetched when one of these events occurs:invalidateAll().invalidateevent arrives withtype: "clients"(handled infrontend/src/api/websocketBridge.ts:33-45).The backend job
internal/web/job/xray_traffic_job.goruns on every traffic poll and broadcasts two WebSocket events:BroadcastTraffic— updates the online/offline badge list only.BroadcastClientStats— carries per-client traffic counters for all clients.The frontend handler
applyClientStatsEvent(useClients.ts:483-513) processes event 2 by iterating over the rows already present in the current page and patching their traffic fields in-place. It does not add rows for clients that were absent when the page loaded, remove rows for clients that have since been deleted, or re-sort the array. Clients who connect after the initial page fetch therefore never appear until the page is manually refreshed.Why the sort order breaks
The sort is computed server-side on the initial fetch.
applyClientStatsEventupdatesrow.traffic.lastOnlinefor existing rows (line 506), but does not reorder the items array to match the new values. After an in-place update, a client whoselastOnlinejust changed stays at its original array position, producing the scrambled order you observe.Why the summary counters stay accurate
The summary card re-computes from
allClientStats(set byapplyClientStatsEventline 487), which carries statistics for all clients regardless of the current page. That is why the online count in the header tracks reality while the table rows do not.When
invalidateis sent and when it is notxray_traffic_job.goonly issuesBroadcastInvalidate(MessageTypeInbounds)when clients are disabled due to quota exhaustion (line 58). Thenode_traffic_sync_job.gosendsBroadcastInvalidate(MessageTypeClients)only on structural changes (j.structural.takeAndReset(), line 168). Neither job broadcasts a clients invalidate on every normal traffic poll, so in a single-node setup without quota events the list is never server-refreshed by WebSocket alone.The combination of
staleTime: Infinityand an in-place patch strategy that cannot account for new or reordered rows reproduces all steps you listed exactly.This comment was generated automatically; a maintainer may follow up.