Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch panic in executeHook #4025

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hooks/hookexecution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package hookexecution
import (
"context"
"fmt"
"runtime/debug"
"strings"
"sync"
"time"

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

go func() {
defer func() {
if r := recover(); r != nil {
glog.Errorf("OpenRTB auction recovered panic in module hook %s.%s: %v, Stack trace is: %v",
hw.Module, hw.Code, r, string(debug.Stack()))
}
}()

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
result, err := hookHandler(ctx, moduleCtx, hw.Hook, payload)
Expand Down
Loading