-
Notifications
You must be signed in to change notification settings - Fork 153
Deprecate isRetriableError and ensure isRetryableError functions #1305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
33d0b4e
a7b0d57
ef69a3d
9543613
c8d2503
b868e94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,9 +174,17 @@ class Neo4jError extends GQLError { | |
/** | ||
* Whether the request that caused this error can be safely retried without duplicate commits on the server. | ||
* This does not apply when running auto-commit transactions using {@link Session#run} | ||
* | ||
* @deprecated members using the spelling 'retriable' will be removed in 7.0. Use {@link retryable} instead. | ||
*/ | ||
retriable: boolean | ||
|
||
/** | ||
* Whether the request that caused this error can be safely retried without duplicate commits on the server. | ||
* This does not apply when running auto-commit transactions using {@link Session#run} | ||
*/ | ||
retryable: boolean | ||
|
||
/** | ||
* @constructor | ||
* @param {string} message - the error message | ||
|
@@ -207,27 +215,49 @@ class Neo4jError extends GQLError { | |
*/ | ||
this.name = 'Neo4jError' | ||
|
||
const isRetryableCode = _isRetryableCode(code) | ||
/** | ||
* If the error is considered retriable. | ||
* This does not apply when running auto-commit transactions using {@link Session#run} | ||
* | ||
* @deprecated members using the spelling 'retriable' will be removed in 7.0. Use {@link retryable} instead. | ||
* @type {boolean} | ||
* @public | ||
*/ | ||
this.retriable = isRetryableCode | ||
|
||
/** | ||
* If the error is considered retryable. | ||
* This does not apply when running auto-commit transactions using {@link Session#run} | ||
* | ||
* @type {boolean} | ||
* @public | ||
*/ | ||
this.retriable = _isRetriableCode(code) | ||
this.retryable = isRetryableCode | ||
} | ||
|
||
/** | ||
* Verifies if the given error is retriable. | ||
* | ||
* @deprecated members using the spelling 'retriable' will be removed in 7.0. Use {@link isRetryable} instead. | ||
* @param {object|undefined|null} error the error object | ||
* @returns {boolean} true if the error is retriable | ||
*/ | ||
static isRetriable (error?: any | null): boolean { | ||
return this.isRetryable(error) | ||
} | ||
|
||
/** | ||
* Verifies if the given error is retryable. | ||
* | ||
* @param {object|undefined|null} error the error object | ||
* @returns {boolean} true if the error is retryable | ||
*/ | ||
static isRetryable (error?: any | null): boolean { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can imagine user code that writes to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is true and to some extent a breaking change. However I can't see any real use-case for writing to retriable, and I'm okay with such usage needing to do a small bit of migration since it's a major version release. The alternative would be to still use the value of retriable internally, but then the user would need to use the deprecated member for their code to work, which is worse to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convinced ✔️ Just make sure that the changelog, migration guide, etc. clearly highlights this subtle breakage. |
||
return error !== null && | ||
error !== undefined && | ||
error instanceof Neo4jError && | ||
error.retriable | ||
error.retryable | ||
} | ||
} | ||
|
||
|
@@ -263,18 +293,28 @@ function newGQLError (message: string, cause?: Error, gqlStatus?: string, gqlSta | |
/** | ||
* Verifies if the given error is retriable. | ||
* | ||
* @deprecated members using the spelling 'retriable' will be removed in 7.0. Use {@link isRetryableError} instead. | ||
* @public | ||
* @param {object|undefined|null} error the error object | ||
* @returns {boolean} true if the error is retriable | ||
*/ | ||
const isRetriableError = Neo4jError.isRetriable | ||
|
||
/** | ||
* Verifies if the given error is retryable. | ||
* | ||
* @public | ||
* @param {object|undefined|null} error the error object | ||
* @returns {boolean} true if the error is retryable | ||
*/ | ||
const isRetryableError = Neo4jError.isRetryable | ||
|
||
/** | ||
* @private | ||
* @param {string} code the error code | ||
* @returns {boolean} true if the error is a retriable error | ||
*/ | ||
function _isRetriableCode (code?: Neo4jErrorCode): boolean { | ||
function _isRetryableCode (code?: Neo4jErrorCode): boolean { | ||
return code === SERVICE_UNAVAILABLE || | ||
code === SESSION_EXPIRED || | ||
_isAuthorizationExpired(code) || | ||
|
@@ -313,6 +353,7 @@ export { | |
newError, | ||
newGQLError, | ||
isRetriableError, | ||
isRetryableError, | ||
Neo4jError, | ||
GQLError, | ||
SERVICE_UNAVAILABLE, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.