EntityConflictError

Thrown when a storage operation conflicts with the current entity state.

EntityConflictError is thrown by world implementations when a storage operation conflicts with the current entity state. This includes cases like creating a run that already exists or writing an event that has already been persisted.

It corresponds to HTTP 409 Conflict semantics.

The Workflow runtime handles this error automatically during replay and event deduplication. You will only encounter it when interacting with world storage APIs directly.

import { EntityConflictError } from "workflow/errors"
declare const world: { events: { create(...args: any[]): Promise<any> } }; // @setup
declare const runId: string; // @setup
declare const event: any; // @setup

try {
  await world.events.create(runId, event);
} catch (error) {
  if (EntityConflictError.is(error)) {
    // Event already exists — safe to ignore during replay
  }
}

API Signature

Properties

NameTypeDescription
messagestringThe error message.

Static Methods

EntityConflictError.is(value)

Type-safe check for EntityConflictError instances. Preferred over instanceof because it works across module boundaries and VM contexts.

import { EntityConflictError } from "workflow/errors"
declare const error: unknown; // @setup

if (EntityConflictError.is(error)) {
  // error is typed as EntityConflictError
}