[GH-ISSUE #5434] [Bug]: Deleted clients/configs remain active and can still connect #3796

Closed
opened 2026-10-31 20:35:02 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @rezamoody1 on GitHub (Jun 18, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5434

Describe the bug

I'm facing a bug in 3x-ui v3.3.1. When I delete a client/config from the panel, it doesn't actually get disabled or disconnected. The user can still connect and use the internet even though they are completely removed from the UI.

How to reproduce the problem

clients

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.3.1

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

ubuntu 24

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

  • 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 @rezamoody1 on GitHub (Jun 18, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5434 ### Describe the bug I'm facing a bug in 3x-ui v3.3.1. When I delete a client/config from the panel, it doesn't actually get disabled or disconnected. The user can still connect and use the internet even though they are completely removed from the UI. ### How to reproduce the problem clients ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.3.1 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system ubuntu 24 ### 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 - [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:35:02 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@GlacierLaunch commented on GitHub (Jun 18, 2026):

this is true, same for me @claude

<!-- gh-comment-id:4745936325 --> @GlacierLaunch commented on GitHub (Jun 18, 2026): this is true, same for me @claude
Author
Owner

@vrcher commented on GitHub (Jun 20, 2026):

I've noticed the same problem in the latest version; when switching users, duplicates are sometimes created or the information doesn't update. A “database is locked” error may also appear. I have several nodes configured.

<!-- gh-comment-id:4759583841 --> @vrcher commented on GitHub (Jun 20, 2026): I've noticed the same problem in the latest version; when switching users, duplicates are sometimes created or the information doesn't update. A “database is locked” error may also appear. I have several nodes configured.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 20, 2026):

Claude finished @MHSanaei's task in 8m 52s —— View job


Analysis and fix for #5434

  • Gather context from issue
  • Trace client deletion flow in the codebase
  • Check Xray config reload after client deletion
  • Check multi-node sync behavior
  • Implement fix
  • Push (permission denied — see below)

Root cause

In internal/web/service/client_inbound_apply.go, DelInboundClientByEmail skips the live Xray runtime removal when emailShared=true (i.e. the client email also appears in at least one other inbound):

// Both the nodePushPlan call and the runtime removal were gated on !emailShared:
var rt runtime.Runtime
var push bool
if len(email) > 0 && !emailShared && (oldInbound.NodeID != nil || needApiDel) { // ← bug
    ...
}
...
if len(email) > 0 && !emailShared {  // ← bug
    if oldInbound.NodeID == nil {
        if needApiDel {
            rt.RemoveUser(ctx, oldInbound, email)  // never reached when emailShared=true
        }
    }
}

Each inbound in Xray is a separate handler with its own user list. Whether the email exists in another inbound has no bearing on whether it must be evicted from this inbound's handler. By skipping RemoveUser / DeleteUser when emailShared=true, the user's session on the deleted inbound is never terminated. Because needRestart is also never set in this branch, the 30-second restart cron (@every 30s IsNeedRestartAndSetFalse) is never triggered either, so the stale active session persists indefinitely.

emailShared is only relevant for deciding whether to delete traffic stats and IPs (which must be preserved if the email still lives in another inbound). It must not prevent the per-inbound Xray handler cleanup.

The batch path (delInboundClients, used by Bulk Detach) already called RemoveUser regardless of emailShared — this fix brings the single-delete path in line with it.

Fix (commit 1b3afa8)

-	if len(email) > 0 && !emailShared && (oldInbound.NodeID != nil || needApiDel) {
+	// nodePushPlan is needed for both the Xray API removal (local) and the node
+	// push (remote). Resolve it whenever a runtime operation may follow, regardless
+	// of emailShared — emailShared only gates traffic/IP deletion, not per-inbound
+	// handler cleanup.
+	if len(email) > 0 && (oldInbound.NodeID != nil || needApiDel) {
 		r, p, dirty, perr := inboundSvc.nodePushPlan(oldInbound)
 		...
 	}
 	...
-	// Apply the runtime delete after commit
-	if len(email) > 0 && !emailShared {
+	// Apply the runtime delete after commit. Each Xray inbound is a separate handler
+	// with its own user list; whether the email appears in other inbounds is
+	// irrelevant to whether it must be evicted from this handler.
+	if len(email) > 0 {
 		if oldInbound.NodeID == nil {
 			if needApiDel {
 				rt.RemoveUser(ctx, oldInbound, email)
 			}
 		} else {
 			rt.DeleteUser(ctx, oldInbound, email)
 		}
 	}

Note on push permission

The GitHub App token used by this action does not have write access to this repository. The commit exists locally (1b3afa8) but could not be pushed. The maintainer can apply the fix manually or grant write access to the App.

The secondary issue reported by @vrcher (database locked / duplicates on multi-node) is a distinct SQLite contention problem and is not addressed by this fix.

<!-- gh-comment-id:4759653975 --> @github-actions[bot] commented on GitHub (Jun 20, 2026): **Claude finished @MHSanaei's task in 8m 52s** —— [View job](https://github.com/MHSanaei/3x-ui/actions/runs/27880580831) --- ### Analysis and fix for #5434 - [x] Gather context from issue - [x] Trace client deletion flow in the codebase - [x] Check Xray config reload after client deletion - [x] Check multi-node sync behavior - [x] Implement fix - [ ] Push (permission denied — see below) ### Root cause In `internal/web/service/client_inbound_apply.go`, `DelInboundClientByEmail` skips the live Xray runtime removal when `emailShared=true` (i.e. the client email also appears in at least one other inbound): ```go // Both the nodePushPlan call and the runtime removal were gated on !emailShared: var rt runtime.Runtime var push bool if len(email) > 0 && !emailShared && (oldInbound.NodeID != nil || needApiDel) { // ← bug ... } ... if len(email) > 0 && !emailShared { // ← bug if oldInbound.NodeID == nil { if needApiDel { rt.RemoveUser(ctx, oldInbound, email) // never reached when emailShared=true } } } ``` Each inbound in Xray is a **separate handler** with its own user list. Whether the email exists in another inbound has no bearing on whether it must be evicted from **this** inbound's handler. By skipping `RemoveUser` / `DeleteUser` when `emailShared=true`, the user's session on the deleted inbound is never terminated. Because `needRestart` is also never set in this branch, the 30-second restart cron (`@every 30s IsNeedRestartAndSetFalse`) is never triggered either, so the stale active session persists indefinitely. `emailShared` is only relevant for deciding whether to delete traffic stats and IPs (which must be preserved if the email still lives in another inbound). It must not prevent the per-inbound Xray handler cleanup. The batch path (`delInboundClients`, used by Bulk Detach) already called `RemoveUser` regardless of `emailShared` — this fix brings the single-delete path in line with it. ### Fix (commit `1b3afa8`) ```diff - if len(email) > 0 && !emailShared && (oldInbound.NodeID != nil || needApiDel) { + // nodePushPlan is needed for both the Xray API removal (local) and the node + // push (remote). Resolve it whenever a runtime operation may follow, regardless + // of emailShared — emailShared only gates traffic/IP deletion, not per-inbound + // handler cleanup. + if len(email) > 0 && (oldInbound.NodeID != nil || needApiDel) { r, p, dirty, perr := inboundSvc.nodePushPlan(oldInbound) ... } ... - // Apply the runtime delete after commit - if len(email) > 0 && !emailShared { + // Apply the runtime delete after commit. Each Xray inbound is a separate handler + // with its own user list; whether the email appears in other inbounds is + // irrelevant to whether it must be evicted from this handler. + if len(email) > 0 { if oldInbound.NodeID == nil { if needApiDel { rt.RemoveUser(ctx, oldInbound, email) } } else { rt.DeleteUser(ctx, oldInbound, email) } } ``` ### Note on push permission The GitHub App token used by this action does not have write access to this repository. The commit exists locally (`1b3afa8`) but could not be pushed. The maintainer can apply the fix manually or grant write access to the App. The secondary issue reported by `@vrcher` (database locked / duplicates on multi-node) is a distinct SQLite contention problem and is not addressed by this fix.
Author
Owner

@MHSanaei commented on GitHub (Jun 21, 2026):

Fixed on main by #5352 (commit cbb21b75, "fix(nodes): propagate single-client deletion to remote nodes").

Deleting a client now:

  • removes the user live from local xray via the gRPC RemoveUser call (or flags an xray restart if the live call can't be made), and
  • propagates a DeleteUser/detach to remote-node inbounds regardless of the client's enable flag (internal/web/service/client_inbound_apply.go:850-866), marking the node dirty for reconcile on any push failure.

An email tombstone (deleteTombstoneTTL) also prevents a node's next cumulative snapshot from resurrecting the just-deleted client. A regression test (node_dirty_test.go) covers the disabled-client-on-node case.

If you can still reproduce this on a build that includes cbb21b75 (after 3.3.1), please reopen with the panel/node versions and whether the inbound is local or on a node.

<!-- gh-comment-id:4763327092 --> @MHSanaei commented on GitHub (Jun 21, 2026): Fixed on `main` by #5352 (commit `cbb21b75`, "fix(nodes): propagate single-client deletion to remote nodes"). Deleting a client now: - removes the user live from local xray via the gRPC `RemoveUser` call (or flags an xray restart if the live call can't be made), and - propagates a `DeleteUser`/detach to remote-node inbounds **regardless of the client's enable flag** (`internal/web/service/client_inbound_apply.go:850-866`), marking the node dirty for reconcile on any push failure. An email tombstone (`deleteTombstoneTTL`) also prevents a node's next cumulative snapshot from resurrecting the just-deleted client. A regression test (`node_dirty_test.go`) covers the disabled-client-on-node case. If you can still reproduce this on a build that includes `cbb21b75` (after 3.3.1), please reopen with the panel/node versions and whether the inbound is local or on a node.
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#3796
No description provided.