couchbaselabs / Couchbase.Extensions

Extensions for Couchbase for .Net Core
Apache License 2.0
27 stars 14 forks source link

IDistributedCache.GetAsync throws Doc Not Found exception instead of returning null #90

Closed jeffrymorris closed 3 years ago

jeffrymorris commented 4 years ago

Per documentation (https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.distributed.idistributedcache.getasync?view=dotnet-plat-ext-3.1#Microsoft_Extensions_Caching_Distributed_IDistributedCache_GetAsync_System_String_System_Threading_CancellationToken_), GetAsync should return null if DOC_NOT_FOUND returned by couchbase.

zakarias68 commented 3 years ago

To further comment on this, as of now the GetAsync() extension is not handling the DocumentNotFoundException from the Couchbase 3.x SDK and since unhandled, the session middleware is failing to create the cookie needed to lookup the session data. Adding a try...catch(DocumentNotFoundException) { return default; } around the call to the SDK fixed this issue.