cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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

MPasadu
Node Link

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:

               "merge
                    (current:Directory {uncPath:$Path})
                merge
                    (parent:Directory {uncPath:$ParentPath})
                merge
                    (parent)-[:HAS_CHILD_DIRECTORY]->(current)"

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.

3 REPLIES 3

Hi @MPasadu

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

Thanks!

Sorry for the late reply:

               cursor = await session.RunAsync(
                     @"merge
                            (current:Directory {uncPath:$Path})
                       merge
                            (parent:Directory {uncPath:$ParentPath})
                       merge
                            (parent)-[:HAS_CHILD_DIRECTORY]->(current),
                    new
                    {
                        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?