breeze-client / isConcurrencyError
Function: isConcurrencyError()
isConcurrencyError(
error):boolean
Defined in: src/manager/entity-manager.ts:154
Whether an error is an optimistic concurrency conflict - a row changed or deleted by someone else after this client read it.
try {
await em.saveChanges();
} catch (e) {
if (isConcurrencyError(e)) {
// re-read and let the user decide; retrying the same save would fail the same way
}
}This is exact rather than approximate: it is true only when the server said so with ProblemTypes.concurrencyConflict, never inferred from the status code or the message. A 409 from a duplicate key is not a concurrency conflict, and matching on message text breaks when the ORM, database or server version changes.
A Breeze .NET server sends this for EF Core's DbUpdateConcurrencyException and NHibernate's StaleObjectStateException. A server that does not send a type - any pre-3.0 Breeze server, and most non-Breeze ones - returns false here, and there is nothing reliable to use instead.
When the conflict names the rows involved, they are on entityErrors with the entities attached:
const stale = (e.entityErrors ?? [])
.filter(ee => ee.errorName === "ConcurrencyError")
.map(ee => ee.entity);Parameters
error
any
The rejection value from a Breeze call - typically a SaveError.
Returns
boolean
true if the server identified this as a concurrency conflict.