flipped-aurora/gin-vue-admin · error
panic: %v
Error message
panic: %v
What it means
runMethod runs the task function in a goroutine and recovers panics, converting them into an error "panic: %v" delivered over the done channel. The timed task itself panicked; the runner can't strongly kill goroutines, so this is the post-hoc report of the crash.
Source
Thrown at server/service/system/sys_timed_task_runner.go:109
s.alertFailure(t, errMsg)
}
}
// runMethod 执行已注册本体方法。
// 超时语义: 只能标记状态, goroutine 无法强杀; 任务函数应响应 ctx 取消。
func (s *TimedTaskService) runMethod(t system.SysTimedTask) (string, error) {
fn, ok := task.Get(t.MethodName)
if !ok {
return "", fmt.Errorf("方法 %s 未注册(需在 initialize/timer.go 经 task.Register 注册)", t.MethodName)
}
ctx, cancel := context.WithTimeout(datascope.WithSystem(context.Background()), defaultMethodTimeout)
defer cancel()
done := make(chan error, 1)
go func() {
defer func() {
if r := recover(); r != nil {
done <- fmt.Errorf("panic: %v", r)
}
}()
done <- fn(ctx, json.RawMessage(t.Params))
}()
select {
case err := <-done:
if err != nil && errors.Is(err, context.DeadlineExceeded) {
return "", errTaskTimeout
}
return "", err
case <-ctx.Done():
return "", errTaskTimeout
}
}
// runHTTP 执行 HTTP 回调(SSRF 防护见 sys_timed_task_http.go)
func (s *TimedTaskService) runHTTP(t system.SysTimedTask) (string, error) {
u, err := url.Parse(t.HttpUrl)View on GitHub (pinned to 3136500ef3)
Solutions
- Read the %v payload in the error to identify the panic site and fix the underlying bug in the task function
- Add defensive checks in the task function for nil dependencies and malformed params before use
- Unmarshal t.Params safely inside the task (json.RawMessage) and validate fields before use
Example fix
// before
var cfg map[string]string
json.Unmarshal(params, &cfg)
url := cfg["url"] // may panic if params nil
// after
var cfg map[string]string
if err := json.Unmarshal(params, &cfg); err != nil { return err }
url, ok := cfg["url"]; if !ok { return errors.New("missing url") } Defensive patterns
Strategy: try-catch
Try / catch
err := RunTask(t)
if err != nil {
var pe *PanicLikeError
if strings.HasPrefix(err.Error(), "panic: ") {
log.Errorf("timed task %s panicked: %v", t.MethodName, err)
}
} Prevention
- Keep task functions small and nil-check all inputs (params, config, globals)
- Validate/unmarshal t.Params defensively at the top of each task function
- Write unit tests for each registered task function covering empty/invalid params
When it happens
Trigger: The registered task function (or anything it calls) panics — nil pointer dereference, index out of range, panic() called explicitly — while executing with the task's ctx and JSON params.
Common situations: Task function assumes config/DB initialized but runs in an environment where they're nil; malformed JSON params cause a downstream panic; bug in task code triggered only with certain parameter values.
Related errors
- executorType 必须为 %s 或 %s
- 任务名 %s 已存在
- 未知执行器类型: %s
- 方法 %s 未注册(需在 initialize/timer.go 经 task.Register 注册)
- 当前响应不支持流式输出
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/15e42bfb15db9391.
Report an issue: GitHub.