mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5469] [MERGED] fix(node): mark node dirty on Update so sync reconciles before snapsh… #5891
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#5891
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/5469
Author: @NikanZeyaei
Created: 6/21/2026
Status: ✅ Merged
Merged: 6/21/2026
Merged by: @MHSanaei
Base:
main← Head:fix/node-update-marks-dirty📝 Commits (1)
b2d5386fix(node): mark node dirty on Update so sync reconciles before snapshot sweep📊 Changes
2 files changed (+53 additions, -0 deletions)
View changed files
📝
internal/web/service/node.go(+3 -0)📝
internal/web/service/node_dirty_test.go(+50 -0)📄 Description
Summary
Closes https://github.com/MHSanaei/3x-ui/issues/5461
Fixes inbounds being deleted when editing or replacing a node.
NodeService.Update()now marks the nodeconfig_dirtyafter writing the row, so the next traffic-sync tick reconciles the remote (pushing the panel's local inbounds to it) before pulling a traffic snapshot. Previously the orphan sweep insetRemoteTrafficLockedtreated the freshly-empty snapshot of a re-pointed node as authoritative and deleted every central inbound absent from it.Why
Editing or re-pointing a node in the 3x-ui panel caused all its associated inbounds to be deleted within ~5 seconds (one traffic-sync tick). The user had to manually recreate the inbounds after every node edit, or work around it by disabling the node before editing and re-enabling it after.
Root cause:
NodeService.Update()invalidated the cached HTTP connection (so the next request hit the new address) but never setconfig_dirty. Every inbound-edit path (inbound.go,client_bulk.go,client_inbound_apply.go,inbound_traffic.go) already callsMarkNodeDirtyon the owning node, which is what causes the sync job to runReconcileNodefirst and push the panel's inbounds to the remote before consuming a snapshot.Update()was the only node-mutating path that did not, so the sync job skipped reconciliation, fetched a snapshot from the new (empty) server, and the orphan sweep deleted every central inbound whose tag was missing from that snapshot.Type of change
Areas affected
How was this tested?
go build ./...— passes.Implementation details
Backend —
internal/web/service/node.go:s.MarkNodeDirty(id)call inNodeService.Update()immediately after the row write succeeds and beforemgr.InvalidateNode(id).MarkNodeDirtyis the same primitive every inbound-edit path uses: it setsconfig_dirty = trueand stampsconfig_dirty_at. On the next sync tick,syncOnesees the flag, callsReconcileNode(which pushes every central inbound tagged for that node to the remote), thenClearNodeDirty, then pulls the traffic snapshot. The orphan sweep's existingif dirty { continue }guard then protects the central inbounds during the first post-edit snapshot.MarkNodeDirtyare logged and swallowed (the row write already succeeded; returning an error now would show a failure toast while the node was in fact updated). This matches the established pattern ininbound.go:663-665.Update()(not gated on whether address/port changed).inbound_sync_modeandinbound_tagsalso affect whatReconcileNodepushes, so dirtying on those edits is correct, and a no-op reconcile on a pure name/remark edit is harmless.SetEnable/Create/Deleteare deliberately not changed: a brand-new node has no central inbounds to delete,Deletealready refuses to remove a node with attached inbounds, andSetEnableis fine because any inbound edit performed while the node was disabled already marked it dirty.Tests —
internal/web/service/node_dirty_test.go:TestNodeService_UpdateMarksNodeDirty: creates a node, callsUpdate()to change address/port (the "replace node" case from the bug report), assertsconfig_dirtyis nowtrue, and asserts the address/port row write persisted. Fails on unfixed code with the message "Update must mark the node config-dirty so sync reconciles before snapshot sweep (#5461)".Files changed
internal/web/service/node.gointernal/web/service/node_dirty_test.goScreenshots / recordings
N/A
Breaking changes
None
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass. (N/A — no frontend change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.