ServiceStack / Issues

Issue Tracker for the commercial versions of ServiceStack
11 stars 6 forks source link

RavenDbUserAuthRepository throws 'NotSupportedException: You can't get a sync query from async session' when GetUserAuthByUserNameAsync is called #747

Closed zeko77 closed 3 years ago

zeko77 commented 3 years ago

Version: 5.10.5

Module: ServiceStack.Authentication.RavenDb

File: RavenDbUserAuthRepositoryAsync.cs

RavenDB.Client version: 5.1.2

Method: GetUserAuthByUserNameAsync

Line: 115

Issue: An async query is requested by synchronous session. This throws: NotSupportedException: You can't get a sync query from async session.

using var session = documentStore.OpenSession(); var authDetails = await session.Query<...>().FirstOrDefaultAsync(token).ConfigAwait();

There are several other methods with the same issue, like GetUserAuthDetailsAsync etc.

Most of the asnyc calls are wrapped synchronous raven calls.

Generally, async implementation should be done with async sessions (documentStore.OpenAsyncSession()) and async calls to raven.

mythz commented 3 years ago

Is this an issue with the RavenDB.Client v4.2.106 that ServiceStack.Authentication.RavenDb depends on?

RavenDB.Client v5 is a breaking change & why we only support v4.

mythz commented 3 years ago

I've upgraded ServiceStack.Authentication.RavenDb to use the latest RavenDB.Client v5.1.2 and updated all async APIs to use OpenAsyncSession() which should resolve this issue.

This change is available from the latest v5.10.5 that's now available on MyGet, as you already have v5.10.5 installed you'll need to clear your NuGet packages cache to download the latest version.