[GH-ISSUE #6329] [Bug]: Selecting an existing node inbound in the central panel deletes it from the node #4297

Closed
opened 2026-10-31 20:38:39 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @S0rushSotoudeh on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6329

Describe the bug

When multiple nodes are connected to a central 3x-ui panel, selecting an existing node inbound from the central panel unexpectedly deletes that inbound from the node.

The inbound is created directly through the node’s own panel and works correctly. However, when I open the Nodes section in the central panel and select that inbound so it can be managed or displayed among the central panel’s inbounds, the central panel removes the inbound from the node instead.

How to reproduce the problem

  1. Connect one or more 3x-ui nodes to a central panel.
  2. Open the panel of one of the connected nodes.
  3. Create a new inbound directly on that node.
  4. Verify that the inbound exists and works correctly.
  5. Open the central panel.
  6. Go to the Nodes section and select the affected node.
  7. Select the newly created inbound so that it is included in the central panel’s inbound list.
  8. Check the node’s own panel again.
  9. The inbound has been deleted from the node.

Expected behavior

Selecting an existing node inbound in the central panel should import, synchronize, or display it in the central panel without deleting it from the node.

Actual behavior

The central panel deletes the selected inbound from the node instead of synchronizing or importing it.

Relevant logs


Screenshots

No response

3x-ui version

3.7.0

Xray-core version

26.7.28

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24

Which parts of the panel are affected?

Multi-node (sub-nodes)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

Yes — Cloudflare (proxied DNS)

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @S0rushSotoudeh on GitHub (Aug 25, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6329 ### Describe the bug When multiple nodes are connected to a central 3x-ui panel, selecting an existing node inbound from the central panel unexpectedly deletes that inbound from the node. The inbound is created directly through the node’s own panel and works correctly. However, when I open the **Nodes** section in the central panel and select that inbound so it can be managed or displayed among the central panel’s inbounds, the central panel removes the inbound from the node instead. ### How to reproduce the problem 1. Connect one or more 3x-ui nodes to a central panel. 2. Open the panel of one of the connected nodes. 3. Create a new inbound directly on that node. 4. Verify that the inbound exists and works correctly. 5. Open the central panel. 6. Go to the **Nodes** section and select the affected node. 7. Select the newly created inbound so that it is included in the central panel’s inbound list. 8. Check the node’s own panel again. 9. The inbound has been deleted from the node. ### Expected behavior Selecting an existing node inbound in the central panel should import, synchronize, or display it in the central panel without deleting it from the node. ### Actual behavior The central panel deletes the selected inbound from the node instead of synchronizing or importing it. ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.7.0 ### Xray-core version 26.7.28 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24 ### Which parts of the panel are affected? Multi-node (sub-nodes) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? Yes — Cloudflare (proxied DNS) ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:38:39 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Aug 25, 2026):

Confirmed — this is a real bug, and it is the remaining gap in the sweep guard that was added for #5898 and narrowed again for #6283. Selecting an existing node inbound in Selected inbounds mode makes the master delete it from the node, because the delete sweep runs before the import that would have created the central row.

What actually happens

Saving the node form writes inbound_tags and marks the node config-dirty in the same transaction — internal/web/service/node.go:585 and internal/web/service/node.go:592:

"inbound_tags":          string(inboundTagsJSON),
...
return s.MarkNodeDirtyTx(tx, id)

On the next 5 s traffic-sync tick, syncOne reconciles the dirty node first and only then pulls the snapshot that would import the inbound — internal/web/job/node_traffic_sync_job.go:367 and :390:

if n.ConfigDirty {
    reconcileErr := j.inboundService.ReconcileNode(reconcileCtx, rt, n)
...
snap, err := rt.FetchTrafficSnapshot(ctx)

Inside ReconcileNode, desiredTags is built only from inbounds already in the master DB (internal/web/service/inbound_node.go:96 → Where("node_id = ?", nodeID), then :113). Your newly created node-side inbound has no central row yet, so its tag is absent from desiredTags. The sweep then reads a selected-but-unimported tag as "the master deleted this" — internal/web/service/inbound_node.go:181-192:

for _, tag := range remoteTags {
	if _, want := desiredTags[tag]; want {
		continue
	}
	if selected != nil {
		if _, managed := selected[tag]; !managed {
			continue
		}
	}
	if err := rt.DelInbound(ctx, &model.Inbound{Tag: tag}); err != nil {

Remote.DelInbound posts panel/api/inbounds/del/<id> to the node (internal/web/runtime/remote.go:437), so the inbound and its clients are gone on the node. The import path that would have created the central row (internal/web/service/inbound_node.go:693, tx.Create(&newIb)) never gets the chance — by the time the snapshot is fetched the inbound no longer exists.

Why the existing guard does not catch it

The #5898 fix (200ea091) only skips the sweep before the node's first adoption — internal/web/service/inbound_node.go:167:

if n.InboundsAdoptedAt == 0 {
    return errors.Join(errs...)
}

Your node has already synced once, so inbounds_adopted_at is non-zero and the gate is open. Note that upgrading also seeds every pre-existing node as adopted (seedNodeInboundsAdopted, internal/database/db.go:1327), so any node that was already connected is in this state. The #6283 follow-up (a255ab7c) only stopped the flag being stamped by a sync that adopted nothing; it did not cover a tag selected later, which #6283 itself called out ("any tag selected later is swept because the master holds no inbound under it").

Both fixes are in v3.7.0 (git tag --contains 200ea091 / a255ab7c → v3.7.0), and the sweep loop above is unchanged on the default branch, so this is still present at the tip.

The Load inbounds from node button is read-only and does not import anything — POST /panel/api/nodes/inbounds (internal/web/controller/node.go:41) calls GetRemoteInboundOptions (internal/web/service/node.go:698), which only fills the tag picker. Selecting an entry marks the tag master-owned while the master holds no matching inbound, which is exactly the state the sweep destroys.

Workaround until this is fixed

Do not create the inbound on the node and then select it. Create it from the central panel with the node chosen as its target: that path stores the central row and adds the tag to the node's selection in the same transaction (EnsureInboundTagAllowedTx, internal/web/service/inbound.go:1125), so the sweep always sees it as desired.

Switching the node to All inbounds is not a safe alternative here — saving the node still marks it dirty, and with selected == nil the sweep deletes every remote tag missing from the master DB, including the new one.

Verdict: Confirmed bug
Severity: High
Confidence: High
Root cause: InboundService.ReconcileNode, internal/web/service/inbound_node.go:181-192. In selected sync mode the delete sweep treats a tag that is in Node.InboundTags but has no inbounds row with node_id = <node> as "deleted on the master" and calls rt.DelInbound. It cannot distinguish "the panel deleted it while the node was offline" from "the operator just selected it and it has not been imported yet". Triggering condition: n.InboundsAdoptedAt != 0 (any node that has synced once, or any node seeded on upgrade by seedNodeInboundsAdopted, internal/database/db.go:1327) + InboundSyncMode == "selected" + a tag added to InboundTags for an inbound that exists only on the node. Introduced by 554d85c2 ("feat: allow selecting inbounds synchronized from nodes (#5178)"), which added the selected-mode carve-out; the guard added in 200ea091 covers only the pre-adoption case.
Already fixed: Still present on the default branch — internal/web/service/inbound_node.go:181-192 is unchanged at HEAD (f727d04f). 200ea091 (#5898) and a255ab7c (#6283) are both already in v3.7.0 and neither covers this path.
Duplicate of: None. Related: #5898 (same sweep, pre-adoption case, fixed by 200ea091) and #6283 (same sweep, empty-tag-list onboarding case, fixed by a255ab7c) — this is the third uncovered entry point into the same delete loop.
Evidence:

  • internal/web/service/node.go:585,592 — saving the node writes inbound_tags and calls MarkNodeDirtyTx in one transaction.
  • internal/web/job/node_traffic_sync_job.go:367-390 — ReconcileNode runs before FetchTrafficSnapshot, so the delete precedes the import in the same tick.
  • internal/web/service/inbound_node.go:96,113 — desiredTags is built only from rows already in the master DB.
  • internal/web/service/inbound_node.go:167 — if n.InboundsAdoptedAt == 0 { return ... }, the only sweep guard.
  • internal/web/service/inbound_node.go:190 — rt.DelInbound(ctx, &model.Inbound{Tag: tag}); internal/web/runtime/remote.go:437 posts panel/api/inbounds/del/<id> to the node.
  • internal/web/service/inbound_node.go:693 — the adoption path (tx.Create(&newIb)) that would have created the central row.
  • internal/web/service/node.go:698-713 + internal/web/controller/node.go:41 — "Load inbounds from node" is read-only.
  • Existing tests pin the two already-covered cases only: TestReconcileNode_SelectedModeLeavesUnselectedRemoteInbounds (internal/web/service/inbound_node_reconcile_test.go:101) and TestReconcileNode_SkipsSweepBeforeFirstAdoption (:151). Nothing pins a selected but not yet imported tag, which is why this passes CI.
    Not determined: Whether this node was onboarded in selected mode or switched to it from all — the outcome is the same in both, so it does not change the verdict. A successful sweep delete logs nothing on the master (only the failure path at internal/web/service/inbound_node.go:191 does), so the single check that would confirm this exact path on the reporter's instance is the node's access log showing POST /<basePath>/panel/api/inbounds/del/<id> arriving from the master within ~5 s of saving the node form.

Suggested fix: The sweep needs to distinguish "selected and previously imported" from "selected and not imported yet" — a tag the master has never held a row for is a pending import, not a deletion. One option is to skip the delete for a selected tag that has no central row and no deletion tombstone, leaving it for the snapshot merge to adopt on the same tick; another is to make selecting a tag import it synchronously so the central row exists before the node is marked dirty.

@MHSanaei

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5416636833 --> @github-actions[bot] commented on GitHub (Aug 25, 2026): Confirmed — this is a real bug, and it is the remaining gap in the sweep guard that was added for #5898 and narrowed again for #6283. Selecting an existing node inbound in **Selected inbounds** mode makes the master delete it from the node, because the delete sweep runs *before* the import that would have created the central row. ## What actually happens Saving the node form writes `inbound_tags` and marks the node config-dirty in the same transaction — `internal/web/service/node.go:585` and `internal/web/service/node.go:592`: ```go "inbound_tags": string(inboundTagsJSON), ... return s.MarkNodeDirtyTx(tx, id) ``` On the next 5 s traffic-sync tick, `syncOne` reconciles the dirty node **first** and only then pulls the snapshot that would import the inbound — `internal/web/job/node_traffic_sync_job.go:367` and `:390`: ```go if n.ConfigDirty { reconcileErr := j.inboundService.ReconcileNode(reconcileCtx, rt, n) ... snap, err := rt.FetchTrafficSnapshot(ctx) ``` Inside `ReconcileNode`, `desiredTags` is built **only** from inbounds already in the master DB (`internal/web/service/inbound_node.go:96` → `Where("node_id = ?", nodeID)`, then `:113`). Your newly created node-side inbound has no central row yet, so its tag is absent from `desiredTags`. The sweep then reads a selected-but-unimported tag as "the master deleted this" — `internal/web/service/inbound_node.go:181-192`: ```go for _, tag := range remoteTags { if _, want := desiredTags[tag]; want { continue } if selected != nil { if _, managed := selected[tag]; !managed { continue } } if err := rt.DelInbound(ctx, &model.Inbound{Tag: tag}); err != nil { ``` `Remote.DelInbound` posts `panel/api/inbounds/del/<id>` to the node (`internal/web/runtime/remote.go:437`), so the inbound and its clients are gone on the node. The import path that *would* have created the central row (`internal/web/service/inbound_node.go:693`, `tx.Create(&newIb)`) never gets the chance — by the time the snapshot is fetched the inbound no longer exists. ## Why the existing guard does not catch it The `#5898` fix (`200ea091`) only skips the sweep before the node's *first* adoption — `internal/web/service/inbound_node.go:167`: ```go if n.InboundsAdoptedAt == 0 { return errors.Join(errs...) } ``` Your node has already synced once, so `inbounds_adopted_at` is non-zero and the gate is open. Note that upgrading also seeds every pre-existing node as adopted (`seedNodeInboundsAdopted`, `internal/database/db.go:1327`), so any node that was already connected is in this state. The `#6283` follow-up (`a255ab7c`) only stopped the flag being stamped by a sync that adopted nothing; it did not cover a tag selected later, which #6283 itself called out ("any tag selected later is swept because the master holds no inbound under it"). Both fixes are in v3.7.0 (`git tag --contains 200ea091` / `a255ab7c` → `v3.7.0`), and the sweep loop above is unchanged on the default branch, so this is still present at the tip. The **Load inbounds from node** button is read-only and does not import anything — `POST /panel/api/nodes/inbounds` (`internal/web/controller/node.go:41`) calls `GetRemoteInboundOptions` (`internal/web/service/node.go:698`), which only fills the tag picker. Selecting an entry marks the tag master-owned while the master holds no matching inbound, which is exactly the state the sweep destroys. ## Workaround until this is fixed Do not create the inbound on the node and then select it. Create it from the **central panel** with the node chosen as its target: that path stores the central row and adds the tag to the node's selection in the same transaction (`EnsureInboundTagAllowedTx`, `internal/web/service/inbound.go:1125`), so the sweep always sees it as desired. Switching the node to **All inbounds** is *not* a safe alternative here — saving the node still marks it dirty, and with `selected == nil` the sweep deletes every remote tag missing from the master DB, including the new one. Verdict: Confirmed bug Severity: High Confidence: High Root cause: `InboundService.ReconcileNode`, `internal/web/service/inbound_node.go:181-192`. In `selected` sync mode the delete sweep treats a tag that is in `Node.InboundTags` but has no `inbounds` row with `node_id = <node>` as "deleted on the master" and calls `rt.DelInbound`. It cannot distinguish "the panel deleted it while the node was offline" from "the operator just selected it and it has not been imported yet". Triggering condition: `n.InboundsAdoptedAt != 0` (any node that has synced once, or any node seeded on upgrade by `seedNodeInboundsAdopted`, `internal/database/db.go:1327`) + `InboundSyncMode == "selected"` + a tag added to `InboundTags` for an inbound that exists only on the node. Introduced by `554d85c2` ("feat: allow selecting inbounds synchronized from nodes (#5178)"), which added the selected-mode carve-out; the guard added in `200ea091` covers only the pre-adoption case. Already fixed: Still present on the default branch — `internal/web/service/inbound_node.go:181-192` is unchanged at HEAD (`f727d04f`). `200ea091` (#5898) and `a255ab7c` (#6283) are both already in v3.7.0 and neither covers this path. Duplicate of: None. Related: #5898 (same sweep, pre-adoption case, fixed by `200ea091`) and #6283 (same sweep, empty-tag-list onboarding case, fixed by `a255ab7c`) — this is the third uncovered entry point into the same delete loop. Evidence: - `internal/web/service/node.go:585,592` — saving the node writes `inbound_tags` and calls `MarkNodeDirtyTx` in one transaction. - `internal/web/job/node_traffic_sync_job.go:367-390` — `ReconcileNode` runs before `FetchTrafficSnapshot`, so the delete precedes the import in the same tick. - `internal/web/service/inbound_node.go:96,113` — `desiredTags` is built only from rows already in the master DB. - `internal/web/service/inbound_node.go:167` — `if n.InboundsAdoptedAt == 0 { return ... }`, the only sweep guard. - `internal/web/service/inbound_node.go:190` — `rt.DelInbound(ctx, &model.Inbound{Tag: tag})`; `internal/web/runtime/remote.go:437` posts `panel/api/inbounds/del/<id>` to the node. - `internal/web/service/inbound_node.go:693` — the adoption path (`tx.Create(&newIb)`) that would have created the central row. - `internal/web/service/node.go:698-713` + `internal/web/controller/node.go:41` — "Load inbounds from node" is read-only. - Existing tests pin the two already-covered cases only: `TestReconcileNode_SelectedModeLeavesUnselectedRemoteInbounds` (`internal/web/service/inbound_node_reconcile_test.go:101`) and `TestReconcileNode_SkipsSweepBeforeFirstAdoption` (`:151`). Nothing pins a *selected but not yet imported* tag, which is why this passes CI. Not determined: Whether this node was onboarded in `selected` mode or switched to it from `all` — the outcome is the same in both, so it does not change the verdict. A successful sweep delete logs nothing on the master (only the failure path at `internal/web/service/inbound_node.go:191` does), so the single check that would confirm this exact path on the reporter's instance is the **node's** access log showing `POST /<basePath>/panel/api/inbounds/del/<id>` arriving from the master within ~5 s of saving the node form. Suggested fix: The sweep needs to distinguish "selected and previously imported" from "selected and not imported yet" — a tag the master has never held a row for is a pending import, not a deletion. One option is to skip the delete for a selected tag that has no central row and no deletion tombstone, leaving it for the snapshot merge to adopt on the same tick; another is to make selecting a tag import it synchronously so the central row exists before the node is marked dirty. @MHSanaei *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4297
No description provided.