mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5674] [MERGED] fix(balancers): keep mixed strategies on one observer #5954
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#5954
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5674
Author: @nima1024m
Created: 6/30/2026
Status: ✅ Merged
Merged: 7/2/2026
Merged by: @MHSanaei
Base:
main← Head:fix-mixed-observatory-sync📝 Commits (5)
bfbc3affix(balancers): keep mixed strategies on one observeredb44actest(balancers): cover observer strategy combinations5d002c5fix(balancers): clarify observer empty state3347b24fix(balancers): remove mixed observer switch2519465test(balancers): cover observer cleanup on deletion📊 Changes
19 files changed (+496 additions, -63 deletions)
View changed files
📝
frontend/src/pages/xray/balancers/BalancersTab.tsx(+0 -1)📝
frontend/src/pages/xray/balancers/ObservatorySettingsTab.tsx(+13 -21)📝
frontend/src/pages/xray/balancers/balancer-helpers.ts(+29 -23)📝
frontend/src/test/balancer-observatory-sync.test.ts(+260 -5)➕
frontend/src/test/observatory-settings-tab.test.tsx(+47 -0)📝
frontend/src/test/routing-reference-cleanup.test.ts(+121 -0)📝
internal/web/translation/ar-EG.json(+2 -1)📝
internal/web/translation/en-US.json(+2 -1)📝
internal/web/translation/es-ES.json(+2 -1)📝
internal/web/translation/fa-IR.json(+2 -1)📝
internal/web/translation/id-ID.json(+2 -1)📝
internal/web/translation/ja-JP.json(+2 -1)📝
internal/web/translation/pt-BR.json(+2 -1)📝
internal/web/translation/ru-RU.json(+2 -1)📝
internal/web/translation/tr-TR.json(+2 -1)📝
internal/web/translation/uk-UA.json(+2 -1)📝
internal/web/translation/vi-VN.json(+2 -1)📝
internal/web/translation/zh-CN.json(+2 -1)📝
internal/web/translation/zh-TW.json(+2 -1)📄 Description
Summary
This PR fixes how the Xray balancer editor manages
observatoryandburstObservatorywhen different balancer strategies are mixed in the same config.The panel now keeps exactly one observer block active:
randomorroundRobinbalancers without a fallbackburstObservatoryforrandomorroundRobinbalancers withfallbackTagobservatoryforleastPingwhen it is the only observer-backed strategyburstObservatoryforleastLoadburstObservatoryfor mixed configs whereleastPingis combined with any burst-required strategyWhy
Xray exposes both
observatoryandburstObservatorythrough the same globalextension.Observatorydependency. If the generated config contains both blocks, Xray may resolve the regular observatory first. That can leave burst-required strategies, such asleastLoador fallbackrandom/roundRobin, without the burst health-ping behavior they need.Because of that, disjoint selectors do not make it safe to keep one regular observer and one burst observer at the same time. The config should choose one observer type globally, then include the selectors for all balancers that need observer data.
Changes
leastPingselectors inburstObservatory.subjectSelectorwhen any burst-required balancer exists.observatorywhen switching to burst mode, and removed staleburstObservatorywhen onlyleastPingremains.randomandroundRobinbalancers observer-free so they remain simple routing changes.Deletion and Cascade Behavior
The direct balancer deletion and outbound deletion cascade paths both call the same observer sync logic. The new tests cover these important cases:
leastPingbalancer removesobservatoryleastLoador fallback balancer removesburstObservatoryleastPingremains switches fromburstObservatorytoobservatoryleastPingwhile a burst-required balancer remains keepsburstObservatoryand removes theleastPingselectorUser Impact
Users no longer need to choose between Observatory and Burst Observatory manually. The panel derives the correct observer from the balancer strategies and selectors. Existing legacy configs with both observer blocks are still shown, but the UI warns that the mixed state is not supported and will be normalized on save.
Validation
npm testpassed: 46 files / 667 testsnpm test -- src/test/routing-reference-cleanup.test.ts src/test/balancer-observatory-sync.test.ts src/test/observatory-settings-tab.test.tsxpassed: 65 testsnpm run lintpassed with one existing unrelated warning inSettingsPage.tsxgit diff --checkpassed🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.