neo4j / neo4j-javascript-driver

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

Introduce `AbortSignal` to `Driver.executeQuery` #1199

Closed bigmontz closed 2 weeks ago

bigmontz commented 2 weeks ago

⚠️ This API is released as preview. This configuration property enables the cancellation of ongoing queries which was previous not possible when using Driver.executeQuery.

The cancellation is done by closing the session used internally by the driver when execute the query. This means the cancellation is not safe and transaction might be commit apart of the execution being aborted. The cancellation might also triggers errors on the Driver.executeQuery execution.

Example:

const abortController = new AbortController()

// Some event which cancels the query
process.on('SIGINT', () => abortController.abort() )

const result = await driver.executeQuery(query, params, {
    database: 'neo4j',
    signal: abortController.signal
})

⚠️ This API is released as preview.