System.ArgumentNullException: Value cannot be null. (Parameter '_connection') on IResultCursor.ConsumeAsync() calls

I am playing around with the new async driver.

I am reading in a multitude of paths(together with their parent path) from a directory structure. And want to represent it in neo4j using nodes (:Directory {uncPath:$path}). And they should all be connected to each other via [:HAS_CHILD_DIRECTORY].

I am opening a single AsyncSession and then write the transactions in parallel using a Parallel.ForEach. So the order of the paths is random.
This is my cypher code:

                    (current:Directory {uncPath:$Path})
                    (parent:Directory {uncPath:$ParentPath})

I get exceptions on some of the IResultCursor.ConsumeAsync() calls with the following stacktrace:

System.ArgumentNullException: Value cannot be null. (Parameter '_connection')
at Neo4j.Driver.Internal.Throw.ArgumentNullException.If(Func`1 func, String paramName)
at Neo4j.Driver.Internal.Throw.ArgumentNullException.IfNull(Object parameter, String paramName)
at Neo4j.Driver.Internal.AsyncSession.OnResultConsumedAsync()
at Neo4j.Driver.Internal.Result.ResultCursorBuilder.<>c__DisplayClass28_0.<b__0>d.MoveNext()

Some nodes end up not having a HAS_CHILD_DIRECTORY relationship to their parent.

Hi @MPasadu

Can you put your calling code - i.e. the call that sends the cypher, and how you consume it?


Sorry for the late reply:

               cursor = await session.RunAsync(
                            (current:Directory {uncPath:$Path})
                            (parent:Directory {uncPath:$ParentPath})
                        Path = uncPath,
                        ParentPath = parentPath,
                await cursor.ConsumeAsync();

This is wrapped inside a Task.Run which is called inside a foreach loop for every path+parent path pair. Session is created once before the foreach loop.

Could you try getting the session withing the Task.Run i.e. just before your cursor?