dotnet/aspnetcore · error · Error

Invalid sequence number or identifier '${sequenceOrIdentifie

Error message

Invalid sequence number or identifier '${sequenceOrIdentifier}'.

What it means

Thrown by CircuitManager.resolveElement() when the sequenceOrIdentifier is neither a pending JS-added root component container nor a parseable integer sequence number. resolveElement first checks the pending JS container map, then tries Number.parseInt; if both fail the string is not a valid root component target and is rejected.

Source

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

    this.changeActivity(1);
    return sendJSDataStream(this._connection!, data, streamId, chunkSize, () => this.changeActivity(-1));
  }

  public resolveElement(sequenceOrIdentifier: string): LogicalElement {
    // It may be a root component added by JS
    const jsAddedComponentContainer = getAndRemovePendingRootComponentContainer(sequenceOrIdentifier);
    if (jsAddedComponentContainer) {
      return toLogicalElement(jsAddedComponentContainer, true);
    }

    // ... or it may be a root component added by .NET
    const parsedSequence = Number.parseInt(sequenceOrIdentifier);
    if (!Number.isNaN(parsedSequence)) {
      const descriptor = this._componentManager.resolveRootComponent(parsedSequence);
      return toLogicalRootCommentElement(descriptor);
    }

    throw new Error(`Invalid sequence number or identifier '${sequenceOrIdentifier}'.`);
  }

  public getRootComponentManager(): RootComponentManager<ServerComponentDescriptor> {
    return this._componentManager;
  }

  public getEventRegistry(): JSEventRegistry {
    return this._eventRegistry;
  }

  private unhandledError(err: Error): void {
    this._logger.log(LogLevel.Error, err);

    // Disconnect on errors.
    // Trying to call methods on the connection after its been closed will throw.
    this.disconnect();
  }

View on GitHub (pinned to 294cab2f9b)

Solutions

  1. Ensure every root component selector the server attaches is either a numeric sequence registered via RootComponentManager or a container declared client-side via Blazor.rootComponents.add.
  2. Verify RegisteredComponents selectors on the .NET side match the JS registrations exactly.
  3. Match client/server framework versions so the descriptor/selector contract is consistent.
Defensive patterns

Strategy: validation

Validate before calling

// Validate a selector/sequence before resolving:
function isValidTarget(s: string): boolean {
  return /^\d+$/.test(s) || pendingContainerExists(s);
}
if (!isValidTarget(selector)) { throw new Error('Bad root target: ' + selector); }

Type guard

function isRootSequence(s: string): boolean {
  return /^\d+$/.test(s);
}

Prevention

When it happens

Trigger: Server sends a JS.AttachComponent message with a selector/sequence that does not match any registered JS root component container and is not numeric; a malformed component descriptor; mismatched root component registration between server and the JS RegisteredComponents map.

Common situations: Registering root components for JS Blazor (Blazor.rootComponents.registerForJS / add) with a selector that the server references but the client never declared; version skew in component descriptor format; typos in component selector strings.

Related errors


AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06). Data as JSON: /api/errors/43ab4411e957377c. Report an issue: GitHub.