Skip to content

Commit 5cb7608

Browse files
linux019shunj-nb
authored andcommitted
Catch panic in executeHook (prebid#4025)
1 parent 43ee93d commit 5cb7608

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

hooks/hookexecution/execution.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package hookexecution
33
import (
44
"context"
55
"fmt"
6+
"runtime/debug"
67
"strings"
78
"sync"
89
"time"
910

11+
"github.com/golang/glog"
1012
"github.com/prebid/prebid-server/v3/config"
1113
"github.com/prebid/prebid-server/v3/hooks"
1214
"github.com/prebid/prebid-server/v3/hooks/hookstage"
@@ -103,6 +105,13 @@ func executeHook[H any, P any](
103105
hookId := HookID{ModuleCode: hw.Module, HookImplCode: hw.Code}
104106

105107
go func() {
108+
defer func() {
109+
if r := recover(); r != nil {
110+
glog.Errorf("OpenRTB auction recovered panic in module hook %s.%s: %v, Stack trace is: %v",
111+
hw.Module, hw.Code, r, string(debug.Stack()))
112+
}
113+
}()
114+
106115
ctx, cancel := context.WithTimeout(context.Background(), timeout)
107116
defer cancel()
108117
result, err := hookHandler(ctx, moduleCtx, hw.Hook, payload)

0 commit comments

Comments
 (0)