mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5397] [MERGED] fix(jobs): isolate per-node background goroutines from panics #5871
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#5871
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/5397
Author: @n0ctal
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/19/2026
Merged by: @MHSanaei
Base:
main← Head:pr-smellb-goroutine-recover📝 Commits (1)
adf1783fix(jobs): isolate per-node background goroutines from panics📊 Changes
4 files changed (+67 additions, -7 deletions)
View changed files
📝
internal/util/common/err.go(+15 -0)➕
internal/util/common/gorecover_test.go(+41 -0)📝
internal/web/job/node_heartbeat_job.go(+4 -2)📝
internal/web/job/node_traffic_sync_job.go(+7 -5)📄 Description
Summary
Add
common.GoRecover(name, fn)— a goroutine launcher guarded by a recover — and use it for the per-node background job goroutines, so a panic in one no longer crashes the whole panel.Why
A panic in any goroutine without a
recovertakes the entire process down. The per-node heartbeat and traffic-sync goroutines run remote network I/O for every node and had no panic isolation, so a single misbehaving node (or an unexpected response) could crash the master.Scope
common.GoRecover(name, fn)runsfnin a new goroutine under a deferred recover that logs the panic with a stack trace (named, for attribution) instead of letting it crash the processWaitGroup.Done()/ semaphore releases run during panic unwind, so the wait group never stallsrecover()sites are left as-is; other background goroutines can adopt the helper in follow-upsValidation
GoRecover: it runs the function, and a panicking function is recovered (would otherwise crash the test binary)internal/util/commonandinternal/web/jobpackage tests passRisk
Low. Adds a small helper and swaps three goroutine launches to use it; no behaviour change beyond turning a process-wide crash into a logged, isolated panic.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.