-
Notifications
You must be signed in to change notification settings - Fork 155
Description
Bug Report
Trying to run multiple queries on a session with Promise.all fails.
Session docs say:
A Session instance is used for handling the connection and sending queries through the connection. In a single session, multiple queries will be executed serially. In order to execute parallel queries, multiple sessions are required.
FWIW I'm not trying to execute the queries in parallel, this is just a minimal reproduction of an error in a large codebase when upgrading driver from v1.4.x to 6.x, it works on v1.4.x.
The driver throws an error saying I can't run queries on a session with an open transaction, but I don't have an open transaction.
The promise is rejected at
| resultPromise = Promise.reject( |
To reproduce
import neo4j from "neo4j-driver";
const driver = neo4j.driver("neo4j://localhost");
const session = driver.session();
const runQuery = () => session.run("RETURN 1;");
await Promise.all([runQuery(), runQuery()]);> node index.js
node:internal/modules/run_main:123
triggerUncaughtException(
^
Neo4jError: Queries cannot be run directly on a session with an open transaction; either run from within the transaction or use a different session.
at captureStacktrace (/home/dev/node_modules/neo4j-driver-core/lib/result.js:101:17)
at Result.GenericResult (/home/dev/node_modules/neo4j-driver-core/lib/result.js:141:23)
at new Result (/home/dev/node_modules/neo4j-driver-core/lib/result.js:711:42)
at Session._run (/home/dev/node_modules/neo4j-driver-core/lib/session.js:224:16)
at Session.run (/home/dev/node_modules/neo4j-driver-core/lib/session.js:188:27)
at runQuery (file:///home/dev/index.js:5:32)
at file:///home/dev/index.js:7:32
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) {
constructor: [Function: Neo4jError] {
isRetriable: [Function (anonymous)],
isRetryable: [Function (anonymous)]
},
cause: undefined,
gqlStatus: '50N42',
gqlStatusDescription: 'error: general processing exception - unexpected error. Queries cannot be run directly on a session with an open transaction; either run from within the transaction or use a different session.',
diagnosticRecord: { OPERATION: '', OPERATION_CODE: '0', CURRENT_SCHEMA: '/' },
classification: 'UNKNOWN',
rawClassification: undefined,
code: 'N/A',
retriable: false,
retryable: false
}
Node.js v22.20.0
My Environment
Javascript Runtime Version: v22.20.0, v24.4.1
Driver Version: 6.0.1
Neo4j Version and Edition: 5.26.10
Operating System: Fedora 43