mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5898] [Bug]: Loading inbounds from a node deletes existing Reality inbound on the node and returns "record not found" #4087
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#4087
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 @mahdimrm on GitHub (Jul 10, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5898
Describe the bug
We are experiencing a synchronization issue when using the node feature.
A server is running 3x-ui with an existing inbound. We then add this server as a node in another (master) 3x-ui panel and use the Load Inbounds feature.
Instead of importing the inbound correctly, the existing inbound on the node is deleted, and the master panel displays a "record not found" error.
Interestingly, if we manually recreate the exact same inbound on the node (using the same settings, port, protocol, Reality configuration, etc.), the master panel is then able to load the inbound successfully.
This suggests that the original inbound is either being deleted or its database record is becoming invalid during the synchronization process.
How to reproduce the problem
Expected behavior
Loading inbounds from a node should not modify or delete any existing inbounds on the node.
The master panel should simply retrieve and display the existing inbounds without changing the node's database.
Actual behavior
After clicking Load Inbounds, the existing inbound on the node is removed, and the master panel displays a "record not found" error.
Only after manually recreating the inbound on the node does the synchronization succeed.
Relevant logs
Screenshots
No response
3x-ui version
latest
Xray-core version
latest
How did you install 3x-ui?
install.sh script
Operating system
Ubunto24.04
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
Chrome
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jul 10, 2026):
Root cause confirmed in
internal/web/service/inbound_node.go. This is a real defect in the master/node reconcile logic, not a configuration error.Title:
ReconcileNodedeletes a node's real inbounds when it runs before the panel has ever imported them centrallySeverity: High
Category: Correctness
What happens
NodeService.Create(internal/web/service/node.go:419-425) inserts the node withconfig_dirty = falseand does nothing to import the node's existing inbounds. Right after adding a node, the master's owninboundstable has zero rows for it — the node's pre-existing Reality inbound is not yet known centrally.NodeService.Update(internal/web/service/node.go:427-468), which unconditionally callsMarkNodeDirtyTx(line 460) — regardless of which field actually changed.cadenceNodeTraffic = "@every 5s",internal/web/web.go:293,340),NodeTrafficSyncJob.syncOneseesConfigDirty == trueand runsInboundService.ReconcileNode(internal/web/job/node_traffic_sync_job.go:366-368) before any traffic-sync-driven import has had a chance to adopt the node's inbounds.ReconcileNode(internal/web/service/inbound_node.go:89-157) builds its "desired" tag set solely from the master's owninboundsrows for that node (line 96) — still empty at this point — and deletes every remote tag not in that set viart.DelInbound(lines 143-155). In the default "all" sync mode this deletes every inbound the node reports; this exact behavior is proven by the existing testTestReconcileNode_AllModeDeletesUndesiredRemoteInbounds(internal/web/service/inbound_node_reconcile_test.go:124-144). In "selected" mode, the sweep only protects unselected tags (lines 147-151) — a tag the operator just selected via "Load inbounds from node" is exempt from nothing and gets deleted too, because "selected but not yet imported centrally" is indistinguishable in this code from "the panel deleted a previously-managed inbound."rt.DelInbound(internal/web/runtime/remote.go:421-432) issues a realPOST panel/api/inbounds/del/<id>against the node's own API, which runs the sameInboundService.DelInbounda manual delete would (internal/web/controller/inbound.go:178-193) — the inbound row and its running Xray listener are genuinely destroyed on the node, not just unsynced.record not found, whichjsonMsgObj(internal/web/controller/util.go:156-183) appends verbatim to the message shown in the UI — this is why the panel displays that literal string.This also explains the workaround in the report: after recreating the inbound on the node and clicking Load Inbounds again (a plain read,
POST /panel/api/nodes/inbounds→GetRemoteInboundOptions,internal/web/controller/node.go:235-245), the next clean sync tick (config_dirtynowfalse, nothing edited again) takes the ordinary adoption path insetRemoteTrafficLocked(internal/web/service/inbound_node.go:465-538), which only ever creates/updates central rows — it never deletes on the node. No further edit means no furtherMarkNodeDirty, soReconcileNodenever runs again and the import succeeds.Why this matters
A normal, documented multi-node workflow — add a node, then use "Load inbounds from node" to pick which inbounds it syncs — can silently and irreversibly delete a live inbound (and disconnect its clients) on the node, with no confirmation prompt. This defeats the purpose of node onboarding/discovery and can cause a real production outage.
Recommendation (for the maintainer to evaluate; no fix is being applied here)
ReconcileNode's delete sweep run until the node has completed at least one successful, non-dirty adoption cycle (so central rows reflect what already exists on the node) — e.g. gate the sweep on a "first sync completed" flag, or seeddesiredTagsfrom the just-fetched remote snapshot rather than solely from central DB rows when no prior import has happened.NodeService.Create, before the node can ever be marked dirty.NodeService.Updatecould avoid callingMarkNodeDirtyfor edits that don't change the desired inbound set, shrinking the window in which this race is reachable.Workaround until fixed: after adding a node, wait for it to report Status: online and for its inbounds to actually appear in the panel's Inbounds list before editing/saving the node again (switching sync mode, tags, or any other field).
One detail I could not confirm from the report alone: whether the deletion followed a second edit/save of the node (e.g. switching to "Selected inbounds" and saving) or happened on the very first save. @mahdimrm, if you still have it, knowing whether you saved the node's settings more than once before the inbound vanished would help pin the exact trigger — though the underlying defect above is reproducible either way and is independent of that detail.
@MHSanaei for review/fix decision.
This reply was generated automatically; a maintainer may follow up.