mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6209] [MERGED] fix(warp): surface update-clock persistence failures #6172
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#6172
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/6209
Author: @n0ctal
Created: 8/12/2026
Status: ✅ Merged
Merged: 8/13/2026
Merged by: @MHSanaei
Base:
main← Head:codex/upstream-warp-clock-errors📝 Commits (2)
6fa0cd4fix(warp): surface update-clock persistence failures54aa0eaMerge branch 'main' into codex/upstream-warp-clock-errors📊 Changes
5 files changed (+122 additions, -8 deletions)
View changed files
📝
internal/web/controller/xray_setting.go(+2 -2)➕
internal/web/controller/xray_setting_warp_test.go(+71 -0)📝
internal/web/job/warp_ip_job.go(+11 -3)➕
internal/web/job/warp_ip_job_test.go(+29 -0)📝
internal/web/service/setting.go(+9 -3)📄 Description
Summary
The WARP auto-update clock is written and read without checking the result, so a manual rotation can report success while its schedule was never stored, and the scheduled job cannot distinguish a missing setting from a database failure. This surfaces both.
Why
Two separate problems in the same feature:
The API reports success it did not achieve. After a manual IP change or an interval change, the handler resets
warpLastUpdateso the job does not rotate again immediately. The result was discarded, so a failed write produced a success response and a schedule that silently kept the old value.The job cannot see failures at all.
WarpIpJob.Runread the clock withlastUpdate, _ :=. A database failure was indistinguishable from an unset clock, and both landed in the "establish a baseline" branch.Fixing the second one naively breaks the feature, which is worth spelling out because it is not obvious from the call site:
warpLastUpdateis not indefaultValueMap, so on a fresh installgetStringfalls through tokey <warpLastUpdate> not in defaultValueMapand returns an error. An earlyreturnon that error means the baseline is never written, the error never clears, and scheduled rotation stays dead forever.GetWarpLastUpdatetherefore maps "no row" to(0, nil)explicitly and reserves the error for real failures.Scope
internal/web/service/setting.go:GetWarpLastUpdatereads the row directly and treats a missing key as0, not as an error.internal/web/job/warp_ip_job.go: read failures abort the tick with a log line; write failures are logged, and the restart is still scheduled after an IP change that did happen.internal/web/controller/xray_setting.go: the clock write result is returned to the caller.GetWarpLastUpdatehas exactly one caller besides its declaration, the job itself, so the semantic change is contained.Validation
TestWarpIpJobInitializesMissingLastUpdateruns the job against a fresh database and asserts a non-zero baseline row exists afterwards.TestWarpIntervalReportsClockPersistenceFailurecovers the controller path.setting.goreverted, the job test fails withscheduled WARP rotation did not establish its baseline: record not found.go build ./internal/...,go vet, controller/job/service tests,golangci-lint,staticcheck -checks=U1000(host andGOOS=linux),make gen-check: all clean.Risk
Deliberate and worth calling out: when the manual
changeIpaction succeeds but the clock write fails, the API now answers with an error even though the WARP IP has already changed and the Xray restart has already been flagged. The alternative is to keep reporting success and lose the schedule, which is what happens today. The operator should learn that the rotation schedule is not what they think it is.The external WARP endpoint is not exercised by the tests; the successful-rotation path is unchanged and its behaviour follows from the untouched code.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.