From cd67a69b5e95da575d249b8e90ae04f1cb798667 Mon Sep 17 00:00:00 2001 From: Evgeniy Scherbina Date: Mon, 6 Nov 2023 15:00:25 -0500 Subject: [PATCH] Hide memory limit is reached error (#60) --- service/cachemdw/caching_middleware.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/service/cachemdw/caching_middleware.go b/service/cachemdw/caching_middleware.go index 1f36ede..05f4438 100644 --- a/service/cachemdw/caching_middleware.go +++ b/service/cachemdw/caching_middleware.go @@ -4,6 +4,7 @@ import ( "bytes" "io" "net/http" + "strings" "github.com/kava-labs/kava-proxy-service/decode" "github.com/kava-labs/kava-proxy-service/logging" @@ -52,12 +53,13 @@ func (c *ServiceCache) CachingMiddleware( // if request isn't already cached, request is cacheable and response is present in context - cache the response if !isCached && cacheable && ok { headersToCache := getHeadersToCache(w, c.whitelistedHeaders) + memoryLimitIsReachedError := "OOM command not allowed when used memory > 'maxmemory'" if err := c.CacheQueryResponse( r.Context(), decodedReq, typedResponse, headersToCache, - ); err != nil { + ); err != nil && !strings.Contains(err.Error(), memoryLimitIsReachedError) { c.Logger.Error().Msgf("can't validate and cache response: %v", err) } }