Skip to content

Commit 4ae507a

Browse files
authored
Merge pull request #215 from thirdweb-dev/np/catch_panic
catch panic from decodeLogFunc
2 parents f757184 + 4d12177 commit 4ae507a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/common/log.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ func DecodeLogs(chainId string, logs []Log) []*DecodedLog {
112112
for idx, eventLog := range logs {
113113
wg.Add(1)
114114
go func(idx int, eventLog Log, mut *sync.Mutex) {
115+
defer func() {
116+
if err := recover(); err != nil {
117+
log.Error().
118+
Any("chainId", chainId).
119+
Any("Logs", logs).
120+
Int("logIndex", idx).
121+
Str("logAddress", eventLog.Address).
122+
Str("logTopic0", eventLog.Topic0).
123+
Err(fmt.Errorf("%v", err)).
124+
Msg("Caught panic in DecodeLogs, possibly in decodeLogFunc")
125+
}
126+
decodedLogs[idx] = &DecodedLog{Log: eventLog}
127+
}()
115128
defer wg.Done()
116129
decodedLog := decodeLogFunc(&eventLog, mut)
117130
decodedLogs[idx] = decodedLog

0 commit comments

Comments
 (0)