Skip to content

Commit 2dd64d9

Browse files
authored
Merge pull request #492 from ali-ince/1.7-fix-ts-declaration
Define resolver in TS declarations
2 parents fd2da6e + eaee1ab commit 2dd64d9

File tree

6 files changed

+36
-1
lines changed

6 files changed

+36
-1
lines changed

src/v1/internal/transaction-executor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
* limitations under the License.
1818
*/
1919

20-
import { newError, Neo4jError, SERVICE_UNAVAILABLE, SESSION_EXPIRED } from '../error'
20+
import {
21+
newError,
22+
Neo4jError,
23+
SERVICE_UNAVAILABLE,
24+
SESSION_EXPIRED
25+
} from '../error'
2126

2227
const DEFAULT_MAX_RETRY_TIME_MS = 30 * 1000 // 30 seconds
2328
const DEFAULT_INITIAL_RETRY_DELAY_MS = 1000 // 1 seconds

test/internal/transaction-executor.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ describe('TransactionExecutor', () => {
9191
testNoRetryOnUnknownError([LOCKS_TERMINATED_ERROR], 1, done)
9292
})
9393

94+
it('should not retry when transaction work returns promise rejected with unknown error type', async () => {
95+
class MyTestError extends Error {
96+
constructor (message, code) {
97+
super(message)
98+
this.code = code
99+
}
100+
}
101+
102+
const error = new MyTestError('an unexpected error', 504)
103+
const executor = new TransactionExecutor()
104+
const realWork = () => Promise.reject(error)
105+
106+
await expectAsync(
107+
executor.execute(transactionCreator(), tx => realWork())
108+
).toBeRejectedWith(error)
109+
})
110+
94111
it('should stop retrying when time expires', done => {
95112
const executor = new TransactionExecutor()
96113
const usedTransactions = []

test/resources/boltstub/acquire_endpoints_old_routing_procedure.script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
!: BOLT 1
12
!: AUTO RESET
23
!: AUTO PULL_ALL
34

test/resources/boltstub/rediscover_and_read_with_init.script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
!: BOLT 1
12
!: AUTO INIT
23
!: AUTO RESET
34
!: AUTO PULL_ALL

test/types/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ const driver2: neo4j.Driver = neo4j.driver(
2525
neo4j.auth.basic('neo4j', 'password')
2626
)
2727

28+
const address1 = 'db-1.internal:7687'
29+
const address2 = 'db-2.internal:7687'
30+
const driver3: neo4j.Driver = neo4j.driver(
31+
'bolt://localhost',
32+
neo4j.auth.basic('neo4j', 'password'),
33+
{
34+
resolver: address => Promise.resolve([address1, address2])
35+
}
36+
)
37+
2838
const sessionModeRead: string = neo4j.session.READ
2939
const sessionModeWrite: string = neo4j.session.WRITE
3040

types/v1/driver.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ declare interface Config {
6363
connectionTimeout?: number
6464
disableLosslessIntegers?: boolean
6565
logging?: LoggingConfig
66+
resolver?: (address: string) => string[] | Promise<string[]>
6667
}
6768

6869
declare type SessionMode = 'READ' | 'WRITE'

0 commit comments

Comments
 (0)