|
|
|
@ -2,6 +2,9 @@ package fx
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"runtime/debug"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -30,7 +33,8 @@ func DoWithTimeout(fn func() error, timeout time.Duration, opts ...DoOption) err
|
|
|
|
|
go func() {
|
|
|
|
|
defer func() {
|
|
|
|
|
if p := recover(); p != nil {
|
|
|
|
|
panicChan <- p
|
|
|
|
|
// attach call stack to avoid missing in different goroutine
|
|
|
|
|
panicChan <- fmt.Sprintf("%+v\n\n%s", p, strings.TrimSpace(string(debug.Stack())))
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
done <- fn()
|
|
|
|
|