neo4j / neo4j-javascript-driver

Neo4j Bolt driver for JavaScript
https://neo4j.com/docs/javascript-manual/current/
Apache License 2.0
860 stars 147 forks source link

Routing table never fresh with null (default) database name #1138

Closed CarsonF closed 1 year ago

CarsonF commented 1 year ago

Bug Report

When using the default database name the current routing table is never used. The database name is unresolved/null here, thus creating a stubbed table. The table is the resolved and saved with the default name "neo4j". https://github.com/neo4j/neo4j-javascript-driver/blob/5.0/packages/bolt-connection/src/connection-provider/connection-provider-routing.js#L352-L355 So the map.get always misses.

Not sure the best solution here. Maybe save the resolved routing table to null/"" keys as well? Maybe I should somehow grab the resolved database name myself and use it for all future sessions?

My Environment

Javascript Runtime Version: v20.5.1 Driver Version: 5.12.0 Neo4j Version and Edition: 5.10.0 enterprise single Operating System: macOS 13.4

bigmontz commented 1 year ago

Hey @CarsonF, thanks for reporting.

However, this is not an error. The driver does it by design since we need to support home database resolution. The database name is resolved in the first transaction in session and stick with the session for the next transactions. This is not ideal for users which doesn't use this feature and we are already working to minimise these problem. Meanwhile, I suggest to always set the database name when create a session or call executeQuery to avoid unnecessary calls to routing table.