mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6138] [MERGED] fix(xray): synchronize lifecycle state #6101
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#6101
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/6138
Author: @PathGao
Created: 7/29/2026
Status: ✅ Merged
Merged: 7/29/2026
Merged by: @MHSanaei
Base:
main← Head:fix-xray-lifecycle-state📝 Commits (3)
13ebc4afix(xray): synchronize lifecycle snapshotsa7e6148test(xray): cover concurrent lifecycle readscb3518cfix(xray): guard process config snapshots📊 Changes
12 files changed (+275 additions, -87 deletions)
View changed files
📝
internal/web/service/inbound_disable.go(+4 -4)📝
internal/web/service/inbound_node.go(+18 -15)📝
internal/web/service/inbound_traffic.go(+2 -2)📝
internal/web/service/outbound_subscription.go(+2 -2)📝
internal/web/service/server.go(+4 -4)📝
internal/web/service/tgbot/tgbot_client.go(+2 -2)📝
internal/web/service/tgbot/tgbot_report.go(+7 -3)📝
internal/web/service/xray.go(+90 -50)➕
internal/web/service/xray_lifecycle_test.go(+68 -0)📝
internal/web/service/xray_setting.go(+2 -2)📝
internal/xray/process.go(+11 -3)➕
internal/xray/process_version_test.go(+65 -0)📄 Description
Summary
Status, result, traffic, Telegram, and outbound-bridge requests could read a different Xray process or configuration than a concurrent restart/hot apply, yielding stale errors, ports, or online-client data. They now retain one lifecycle/configuration snapshot; cached failure output is accepted only from the current process.
Version probing now times out after five seconds, so a replacement binary that hangs on
-versioncannot keep a restart locked indefinitely. The Windows stop result is no longer cached as an error.Validation
make verifygo test -race -shuffle=on -count=1 ./internal/xray ./internal/web/service ./internal/web/service/tgbot -run 'Test(ProcessConfigSnapshotsAreRaceSafe|RefreshVersionTimesOut|XrayLifecycle)'make racealso exposed pre-existing races ininternal/mtprototests; those are outside this PR and will be handled separately.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.