diff --git a/src/v1/internal/transaction-executor.js b/src/v1/internal/transaction-executor.js index cc307078a..6e6672c01 100644 --- a/src/v1/internal/transaction-executor.js +++ b/src/v1/internal/transaction-executor.js @@ -17,7 +17,12 @@ * limitations under the License. */ -import { newError, Neo4jError, SERVICE_UNAVAILABLE, SESSION_EXPIRED } from '../error' +import { + newError, + Neo4jError, + SERVICE_UNAVAILABLE, + SESSION_EXPIRED +} from '../error' const DEFAULT_MAX_RETRY_TIME_MS = 30 * 1000 // 30 seconds const DEFAULT_INITIAL_RETRY_DELAY_MS = 1000 // 1 seconds diff --git a/test/internal/transaction-executor.test.js b/test/internal/transaction-executor.test.js index f4f6c929f..28b706bf0 100644 --- a/test/internal/transaction-executor.test.js +++ b/test/internal/transaction-executor.test.js @@ -91,6 +91,23 @@ describe('TransactionExecutor', () => { testNoRetryOnUnknownError([LOCKS_TERMINATED_ERROR], 1, done) }) + it('should not retry when transaction work returns promise rejected with unknown error type', async () => { + class MyTestError extends Error { + constructor (message, code) { + super(message) + this.code = code + } + } + + const error = new MyTestError('an unexpected error', 504) + const executor = new TransactionExecutor() + const realWork = () => Promise.reject(error) + + await expectAsync( + executor.execute(transactionCreator(), tx => realWork()) + ).toBeRejectedWith(error) + }) + it('should stop retrying when time expires', done => { const executor = new TransactionExecutor() const usedTransactions = [] diff --git a/test/resources/boltstub/acquire_endpoints_old_routing_procedure.script b/test/resources/boltstub/acquire_endpoints_old_routing_procedure.script index 9846be014..2a9db896f 100644 --- a/test/resources/boltstub/acquire_endpoints_old_routing_procedure.script +++ b/test/resources/boltstub/acquire_endpoints_old_routing_procedure.script @@ -1,3 +1,4 @@ +!: BOLT 1 !: AUTO RESET !: AUTO PULL_ALL diff --git a/test/resources/boltstub/rediscover_and_read_with_init.script b/test/resources/boltstub/rediscover_and_read_with_init.script index c2ce54c6f..9c2c0245b 100644 --- a/test/resources/boltstub/rediscover_and_read_with_init.script +++ b/test/resources/boltstub/rediscover_and_read_with_init.script @@ -1,3 +1,4 @@ +!: BOLT 1 !: AUTO INIT !: AUTO RESET !: AUTO PULL_ALL diff --git a/test/types/index.test.ts b/test/types/index.test.ts index 6ba5653cd..12579c7c4 100644 --- a/test/types/index.test.ts +++ b/test/types/index.test.ts @@ -25,6 +25,16 @@ const driver2: neo4j.Driver = neo4j.driver( neo4j.auth.basic('neo4j', 'password') ) +const address1 = 'db-1.internal:7687' +const address2 = 'db-2.internal:7687' +const driver3: neo4j.Driver = neo4j.driver( + 'bolt://localhost', + neo4j.auth.basic('neo4j', 'password'), + { + resolver: address => Promise.resolve([address1, address2]) + } +) + const sessionModeRead: string = neo4j.session.READ const sessionModeWrite: string = neo4j.session.WRITE diff --git a/types/v1/driver.d.ts b/types/v1/driver.d.ts index 3a18e493c..2b9199c3a 100644 --- a/types/v1/driver.d.ts +++ b/types/v1/driver.d.ts @@ -63,6 +63,7 @@ declare interface Config { connectionTimeout?: number disableLosslessIntegers?: boolean logging?: LoggingConfig + resolver?: (address: string) => string[] | Promise } declare type SessionMode = 'READ' | 'WRITE'