• Start

API Reference

/

Utilities

isRetryableConflict

Default predicate used to detect retryable write conflicts.

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 isRetryableConflict(error: Error): boolean

Parameter

Type

Description

errorError

The error thrown by a failed query.

boolean - true if the error looks like a retryable write conflict (its message contains "conflict" or "can be retried"), false otherwise

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();
Note

Confirm the exact conflict message against the SurrealDB server version you target — the heuristic matches on message text rather than a structured error kind.

Was this page helpful?