Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.InvalidOperationException when disposing a read transaction #191

Open
RolandKoenig opened this issue Mar 13, 2022 · 1 comment
Open

Comments

@RolandKoenig
Copy link

I'm testing a few cases with Nevermore and encountered an exeception when disposes a ReadTransaction:
System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.

You can see the code here:
The exeception is thrown on the end of the program (when dispose is called because of the using statement in line 74)
https://github.com/RolandKoenig/HappyCoding/blob/main/2022/HappyCoding.JsonDocumentsWithNevermore/HappyCoding.JsonDocumentsWithNevermore/Program.cs
I'm using the version 17.0.1 of Nevermore

Is there anything wrong with my code or is this a bug?

@PaulStovell
Copy link
Member

This call needs an 'await', otherwise you are telling the GC to keep alive the task that will eventually load the document, not the document itself:

            var readDocument =
                readTransaction.LoadRequiredAsync<TestingDocument>(expectedDocument.ID);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants