dotnet/aspnetcore · error · Error

Circuit state ${this._stateName} is in progress

Error message

Circuit state ${this._stateName} is in progress

What it means

`transitionTo(newState)` synchronously moves a settled `CircuitState`'s last value (e.g. marking a circuit 'paused' when the connection drops without a formal pause). It refuses if `_promise` exists, because transitioning while an operation is in flight would race the async settlement — the value should be set by `complete()` instead.

Source

Thrown at src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts:740

    reject(reason);
  }

  public isInprogress(): boolean {
    return !!this._promise;
  }

  public currentProgress(): Promise<T> {
    if (!this.isInprogress()) {
      throw new Error(`Circuit state ${this._stateName} is not in progress`);
    }

    return this._promise!;
  }

  public transitionTo(newState: T): void {
    if (this._promise) {
      throw new Error(`Circuit state ${this._stateName} is in progress`);
    }

    this._lastValue = newState;
  }

  public lastValue() {
    return this._lastValue;
  }
}

View on GitHub (pinned to 3600ca084e)

Solutions

  1. Only call `transitionTo()` when `isInprogress()` is false — defer it until the operation settles.
  2. If you need to set the value during an in-flight operation, let `complete()`/`fail()` set it instead.
  3. Serialize lifecycle transitions so a new transition does not start before the previous one settles.
  4. Review connection close/open handlers for races against explicit pause/resume calls.

Example fix

// before
this._pausingState.transitionTo(true); // throws if a pause is in flight

// after
if (!this._pausingState.isInprogress()) {
  this._pausingState.transitionTo(true);
}
Defensive patterns

Strategy: validation

Validate before calling

function safeTransition<T>(s: { isInprogress(): boolean; transitionTo(v: T): void }, v: T) {
  if (!s.isInprogress()) s.transitionTo(v);
}

Try / catch

try { state.transitionTo(newState); }
catch (e) { if (/is in progress/.test(e.message)) { /* defer until settled */ return; } throw e; }

Prevention

When it happens

Trigger: Calling `transitionTo()` on a `CircuitState` that currently has an in-flight operation (an unsettled `_promise` from `reset()`).

Common situations: Internal logic attempting to mark a state (e.g. paused) while a pause/resume/disconnect is still resolving; a connection-close handler racing with an explicit pause; re-entrant lifecycle calls during reconnect.

Related errors


AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11). Data as JSON: /api/errors/640bc77c37f7396d. Report an issue: GitHub.