Skip to content

Function: isTermChangedConcurrently()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / isTermChangedConcurrently

isTermChangedConcurrently(error): error is ConstraintViolationError

Defined in: src/errors.ts:397

Whether error is the refusal of a write whose read premise another writer broke before its commit (reasoninglayer#1263).

unknown

Anything caught from an SDK call.

error is ConstraintViolationError

true when error is a ConstraintViolationError whose code is term_changed_concurrently; false otherwise.

The body is the coded { error, code, message, refs }: refs.term names the term the request read and another writer changed (read it with errorBodyRefs). Nothing was written; read again and retry. Engine d779b31031 answered the same conflict as an uncoded 409.

try {
await client.reviews.mergeEntity({ reviewId, targetTermId, conflictResolution: 'merge' });
} catch (e) {
if (isTermChangedConcurrently(e)) retryAfterReading();
}