mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5638] [Bug]: State desynchronization between Balancer GUI and Advanced Xray Template (wipes out "observatory" and "fallback", causes exit status 23) #3930
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#3930
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 @regulareverydaynormalmazaf on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5638
Describe the bug
I encountered a critical issue while configuring a load balancer with the Observatory feature in 3x-ui.
The panel's backend constantly overwrites specific routing blocks, causing parameters to silently disappear. Surprisingly, the fallback parameter gets automatically deleted even when edited strictly inside the JSON template file itself. These configuration drops break core dependencies, subsequently leading to validation failures (exit status 23 / dependencies not resolved) upon Xray restart.
There are 4 problem scenarios described below:
Xray Validation Failure: If you create a load balancer and specify the fallback parameter without having the observatory block created first, Xray completely fails to start (exit status 23) upon panel restart.
Template Overwrite (Fallback Drop): If you try to configure everything simultaneously by adding both the observatory block and the balancer with fallback into the Advanced JSON template, the panel silently deletes the "fallback" line from the configuration file after saving. Any subsequent attempts to manually re-add the fallback string directly into the JSON template file result in it being instantly erased after save.
Observatory Wipeout via GUI: If you then try to add the missing fallback parameter using the Balancer GUI instead, the manually created "observatory" block immediately disappears from both the web interface and the JSON configuration template — even without clicking Save or restarting the panel.
Dashboard Bug: Even when the specific workaround sequence is applied and the failover logic actually functions as intended (verified via error logs when forcing a connection timeout), the Dashboard under Xray Metrics -> Observatory still mistakenly displays a placeholder text stating that the feature is not configured.
P.S.
Additionally, the instruction link inside the bug report template ("Please search existing issues...") currently leads to a 404 error page on GitHub.
How to reproduce the problem
Expected behavior
No Silent Drops: The panel should merge and preserve manually added configuration blocks (like "observatory") inside the Advanced Xray Template when interacting with or saving settings via the Balancer GUI.
Persistent Fallback: The "fallback" string should not be automatically stripped from the JSON template if it is valid.
Core Dependency Order: If a balancer requires an observatory block to resolve its fallback logic, the panel should validate their coexistence before generating the final file, rather than dropping parameters and causing an exit status 23 crash.
Dashboard Sync: The Xray Metrics -> Observatory dashboard tab should correctly parse and display status metrics when the feature is active and functional in the running Xray instance.
Actual behavior
The Only Working Order of Steps (Workaround)
To make the setup work without crashes and avoid configuration drops, I had to strictly follow this exact sequence:
Relevant logs
Screenshots
No response
3x-ui version
3.4.1
Xray-core version
26.6.22
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04.4 LTS
Which parts of the panel are affected?
Xray config generation, Statistics / traffic counters
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 28, 2026):
The four scenarios share a single root cause: a mismatch between the type of observatory xray-core requires for a
random/roundRobinbalancer with afallbackTagand what gets placed in the template when the Advanced JSON editor is used instead of the Balancer GUI.Background: two observatory types
xray-core has two observatory variants that serve different strategies:
observatoryleastPingstrategyburstObservatoryleastLoadstrategy, orrandom/roundRobinwith a non-emptyfallbackTagThe panel's
syncObservatoriesfunction (confirmed infrontend/src/pages/xray/balancers/balancer-helpers.ts) enforces this automatically, but only when a change is made through the Balancer GUI (it is called fromonConfirminBalancersTab.tsx). Edits made directly in the Advanced JSON template editor bypasssyncObservatoriesentirely; the raw JSON is saved without any observatory reconciliation.Scenario 1 — exit status 23 when
fallbackTagis set butburstObservatoryis absentConfirmed code path: when xray-core starts with a
randombalancer whosefallbackTagis a non-empty string and noburstObservatorysection exists, it callsRequireFeatures(Observatory)internally and aborts withnot all dependencies are resolved(exit status 23). The comment atbalancer-helpers.ts:34-46documents exactly this xray-core behaviour, referencing issue #5605.If the balancer is created or edited through the Balancer GUI with
fallbackTagset,syncObservatoriescreatesburstObservatoryautomatically and this error cannot occur via that path. The error occurs only whenfallbackTagis added manually in the Advanced editor without simultaneously adding a matchingburstObservatoryblock.Scenario 2 —
fallbackTagappearing to vanish after savingThe backend save pipeline (confirmed in
internal/web/service/xray_setting.go:SaveXraySetting) preserves all JSON fields, includingfallbackTag, through theEnsureStatsRoutingstep and the finalsaveSettingcall. The field is also preserved by the Zod schema on the frontend (BalancerObjectSchemaincludesfallbackTag: z.string().optional(), confirmed infrontend/src/schemas/routing.ts). The template itself does not losefallbackTag.The most likely explanation for the observed "erasure" is Scenario 3 occurring first: if a balancer with manually-set
fallbackTagis subsequently edited through the Balancer GUI,syncObservatoriesrewrites the balancer entry. If thefallbackTagvalue in the form's dropdown was blank (e.g., because the target outbound tag was not in theoutboundTagslist and the Select cleared it),wire.fallbackTagwould be serialized as"", whichhasFallbacktreats as no-fallback, andburstObservatorywould be removed.Scenario 3 —
observatoryblock wiped when interacting with the Balancer GUIConfirmed bug. When
syncObservatoriesruns (triggered by clicking OK in the Balancer add/edit modal), it deletes the top-levelobservatoryblock if noleastPingbalancer exists (balancer-helpers.ts:54-56):A
randombalancer withfallbackTagrequiresburstObservatory, notobservatory. If the user manually added anobservatoryblock (the wrong type for this strategy),syncObservatoriescorrectly removes it and createsburstObservatoryinstead. From the user's perspective, theobservatoryblock disappears as soon as they confirm any GUI edit of the balancer.This is intentional behaviour —
syncObservatoriesenforces correctness — but the UI gives no indication that the manually-addedobservatoryblock is the wrong type for the configured strategy.Scenario 4 — Dashboard "Observatory" tab showing placeholder despite feature working
The panel's metrics service reads observatory data from xray-core's
/debug/varsendpoint under the JSON key"observatory"(internal/web/service/xray_metrics.go:173):If xray-core exposes
burstObservatorydata under a different key (e.g.,"burstObservatory") in that endpoint, the panel would see an empty map and display the "not configured" placeholder. Whether that is the case for xray-core 26.6.22 requires checking against the xray-core source at that version, which is outside this codebase.Working configuration procedure
To use a
randombalancer with fallback failover without hitting any of these issues:Random), and select the fallback outbound from the Fallback dropdown in the form.syncObservatories, which creates theburstObservatoryblock automatically.Do not mix manual
observatoryJSON blocks with the Balancer GUI forrandom/roundRobinstrategies. If the Advanced editor and the Balancer GUI are used together for the same balancer, always use the GUI last sosyncObservatorieshas the final word.P.S. — broken link in the bug report template
The relative URL
../issues?q=is%3Aissuein.github/ISSUE_TEMPLATE/bug_report.yamlresolves incorrectly when the template is rendered in the GitHub UI, producing a 404. It should be an absolute URL:https://github.com/MHSanaei/3x-ui/issues?q=is%3Aissue.This reply was generated automatically; a maintainer may follow up.
@MHSanaei commented on GitHub (Jun 28, 2026):
wait for next version already fixed