neo4j / neo4j-go-driver

Neo4j Bolt Driver for Go
Apache License 2.0
490 stars 69 forks source link

The `sessionWithContext` Session remains indefinitely usable even after explicitly closing it. #567

Closed oleriajm closed 7 months ago

oleriajm commented 7 months ago

The Session must not be usable after the caller closed it explicitly.

Following pattern just works at the moment

    session := driver.NewSession(ctx, sessionConfig)
        session.Close()

        session.ExecuteRead(...)
        // and keep using session with more operations...

This is because Closing session cleans up pool/router etc, but all the references are still preserved.

As a good practice, the behavior should be fail-fast/fail-hard once you called Close on it