Skip to content

Commit

Permalink
Merge pull request #530 from OdyseeTeam/improve-cache
Browse files Browse the repository at this point in the history
Fix nil cache response handling
  • Loading branch information
anbsky authored Nov 28, 2024
2 parents 0010c3e + 1ef83e7 commit 18fd495
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/query/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c *QueryCache) Retrieve(query *Query, getter func() (any, error)) (*Cached
if err != nil {
ObserveQueryCacheOperation(CacheOperationSet, CacheResultError, cacheReq.Method, start)
monitor.ErrorToSentry(fmt.Errorf("error during cache.set: %w", err), map[string]string{ParamMethod: cacheReq.Method})
log.Warnf("error during cache.set: %s", err)
log.Warnf("error during cache.set (query returned): %s", err)
return cacheResp, nil
}
ObserveQueryCacheOperation(CacheOperationSet, CacheResultSuccess, cacheReq.Method, start)
Expand Down Expand Up @@ -240,5 +240,8 @@ func preflightCacheHook(caller *Caller, ctx context.Context) (*jsonrpc.RPCRespon
if err != nil {
return nil, rpcerrors.NewSDKError(err)
}
if cachedResp == nil {
return nil, nil
}
return cachedResp.RPCResponse(query.Request.ID), nil
}

0 comments on commit 18fd495

Please sign in to comment.