The isRetryableConflict() function is the default predicate used by .retry() to decide whether a failed query should be retried. SurrealDB does not currently expose a structured retryable error kind, so the predicate matches on the error message.
Import:
import { isRetryableConflict } from 'surrealdb';Source: utils/index.ts
Function signature
function isRetryableConflict(error: Error): booleanParameters
Parameter | Type | Description |
|---|---|---|
error | Error | The error thrown by a failed query. |
Returns
boolean - true if the error looks like a retryable write conflict (its message contains "conflict" or "can be retried"), false otherwise
Overriding the default predicate
Pass a custom retryable function in RetryOptions to change what counts as retryable, optionally reusing isRetryableConflict as a base:
import { isRetryableConflict } from 'surrealdb';
await db.query('UPDATE counter:c SET n += 1 RETURN n')
.retry({
attempts: 5,
retryable: (error) => isRetryableConflict(error) || error.message.includes('busy')
})
.collect();Confirm the exact conflict message against the SurrealDB server version you target — the heuristic matches on message text rather than a structured error kind.
See also
Query.retry() - Retry queries on write conflict
RetryOptions - Retry configuration type
Error handling - Handling SDK errors