Skip to content

Commit ee72ed0

Browse files
authored
Fail fast for more rediscovery failures (#1011)
When trying to impersonate an invalid user, the routing procedure returns `Neo.ClientError.Statement.ArgumentError`. This type of failure is not in the fail fast list, thus this is wrapped up in the generic rediscovery error triggering the retry in the transaction functions. Since this kind of error is not recoverable, retrying on it is not need and desirable. Then, failing fast on `Neo.ClientError.Statement.ArgumentError` failures speeds up the error bubbling and avoids unnecessary load in the client and server. Other rediscovery failures to be fast failed are: * `Neo.ClientError.Statement.TypeError` * `Neo.ClientError.Request.Invalid`
1 parent b53f683 commit ee72ed0

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

packages/bolt-connection/src/connection-provider/connection-provider-routing.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const INVALID_BOOKMARK_MIXTURE_CODE =
4848
'Neo.ClientError.Transaction.InvalidBookmarkMixture'
4949
const AUTHORIZATION_EXPIRED_CODE =
5050
'Neo.ClientError.Security.AuthorizationExpired'
51+
const INVALID_ARGUMENT_ERROR = 'Neo.ClientError.Statement.ArgumentError'
52+
const INVALID_REQUEST_ERROR = 'Neo.ClientError.Request.Invalid'
53+
const STATEMENT_TYPE_ERROR = 'Neo.ClientError.Statement.TypeError'
5154

5255
const SYSTEM_DB_NAME = 'system'
5356
const DEFAULT_DB_NAME = null
@@ -703,7 +706,10 @@ function _isFailFastError (error) {
703706
return [
704707
DATABASE_NOT_FOUND_CODE,
705708
INVALID_BOOKMARK_CODE,
706-
INVALID_BOOKMARK_MIXTURE_CODE
709+
INVALID_BOOKMARK_MIXTURE_CODE,
710+
INVALID_ARGUMENT_ERROR,
711+
INVALID_REQUEST_ERROR,
712+
STATEMENT_TYPE_ERROR
707713
].includes(error.code)
708714
}
709715

packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,9 @@ describe.each([
16691669
'Neo.ClientError.Database.DatabaseNotFound',
16701670
'Neo.ClientError.Transaction.InvalidBookmark',
16711671
'Neo.ClientError.Transaction.InvalidBookmarkMixture',
1672+
'Neo.ClientError.Request.Invalid',
1673+
'Neo.ClientError.Statement.ArgumentError',
1674+
'Neo.ClientError.Statement.TypeError',
16721675
'Neo.ClientError.Security.Forbidden',
16731676
'Neo.ClientError.Security.IWontTellYou'
16741677
])('with "%s"', errorCode => {

packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const INVALID_BOOKMARK_MIXTURE_CODE =
4848
'Neo.ClientError.Transaction.InvalidBookmarkMixture'
4949
const AUTHORIZATION_EXPIRED_CODE =
5050
'Neo.ClientError.Security.AuthorizationExpired'
51+
const INVALID_ARGUMENT_ERROR = 'Neo.ClientError.Statement.ArgumentError'
52+
const INVALID_REQUEST_ERROR = 'Neo.ClientError.Request.Invalid'
53+
const STATEMENT_TYPE_ERROR = 'Neo.ClientError.Statement.TypeError'
5154

5255
const SYSTEM_DB_NAME = 'system'
5356
const DEFAULT_DB_NAME = null
@@ -703,7 +706,10 @@ function _isFailFastError (error) {
703706
return [
704707
DATABASE_NOT_FOUND_CODE,
705708
INVALID_BOOKMARK_CODE,
706-
INVALID_BOOKMARK_MIXTURE_CODE
709+
INVALID_BOOKMARK_MIXTURE_CODE,
710+
INVALID_ARGUMENT_ERROR,
711+
INVALID_REQUEST_ERROR,
712+
STATEMENT_TYPE_ERROR
707713
].includes(error.code)
708714
}
709715

0 commit comments

Comments
 (0)