{"record":{"id":"43ab4411e957377c","repo":"dotnet/aspnetcore","slug":"invalid-sequence-number-or-identifier-sequenceo","errorCode":null,"errorMessage":"Invalid sequence number or identifier '${sequenceOrIdentifier}'.","messagePattern":"Invalid sequence number or identifier '(.+?)'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts","lineNumber":559,"sourceCode":"    this.changeActivity(1);\n    return sendJSDataStream(this._connection!, data, streamId, chunkSize, () => this.changeActivity(-1));\n  }\n\n  public resolveElement(sequenceOrIdentifier: string): LogicalElement {\n    // It may be a root component added by JS\n    const jsAddedComponentContainer = getAndRemovePendingRootComponentContainer(sequenceOrIdentifier);\n    if (jsAddedComponentContainer) {\n      return toLogicalElement(jsAddedComponentContainer, true);\n    }\n\n    // ... or it may be a root component added by .NET\n    const parsedSequence = Number.parseInt(sequenceOrIdentifier);\n    if (!Number.isNaN(parsedSequence)) {\n      const descriptor = this._componentManager.resolveRootComponent(parsedSequence);\n      return toLogicalRootCommentElement(descriptor);\n    }\n\n    throw new Error(`Invalid sequence number or identifier '${sequenceOrIdentifier}'.`);\n  }\n\n  public getRootComponentManager(): RootComponentManager<ServerComponentDescriptor> {\n    return this._componentManager;\n  }\n\n  public getEventRegistry(): JSEventRegistry {\n    return this._eventRegistry;\n  }\n\n  private unhandledError(err: Error): void {\n    this._logger.log(LogLevel.Error, err);\n\n    // Disconnect on errors.\n    // Trying to call methods on the connection after its been closed will throw.\n    this.disconnect();\n  }\n","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts#L541-L577","documentation":"`resolveElement` maps a `sequenceOrIdentifier` (sent by the server when attaching a root component) to a logical element. It first checks JS-added pending containers, then tries to parse it as a numeric sequence for a .NET-added root component. If neither lookup succeeds the identifier is unresolvable, so it throws to prevent attaching a component to nothing.","triggerScenarios":"The server sends a root-component attach message whose `sequenceOrIdentifier` is neither a pending JS-added container key nor a parseable numeric sequence that `RootComponentManager.resolveRootComponent` can resolve.","commonSituations":"Mismatched client/server versions where the server registers a root component descriptor the client doesn't have; JS-added root components whose container was already consumed/removed before the attach message arrived; desync in root-component registration during hot reload or render-mode changes; corrupted/out-of-order add-root-component operations.","solutions":["Ensure client and server share the same Blazor build so root-component descriptors/sequences agree.","When adding root components from JS, register the container (`addRootComponent`) before the server-side attach can fire, and avoid removing it prematurely.","Review the order of `UpdateRootComponents`/`AddRootComponent` operations to confirm the identifier is valid at attach time.","Capture the offending identifier from the message and correlate with server-side root component registration logs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before attaching, confirm the identifier is resolvable\nfunction canResolve(seq: string, mgr: RootComponentManager<any>): boolean {\n  return getAndRemovePendingRootComponentContainer(seq) !== undefined\n    || !Number.isNaN(Number.parseInt(seq));\n}","typeGuard":null,"tryCatchPattern":"try { return cm.resolveElement(sequenceOrIdentifier); }\ncatch (e) { if (/Invalid sequence/.test(e.message)) { /* drop the attach op, log */ return null; } throw e; }","preventionTips":["Keep client and server Blazor builds identical.","Register JS-added root containers before the server attach fires.","Avoid removing pending containers prematurely.","Sequence UpdateRootComponents operations deterministically."],"tags":["circuit","root-components","rendering","interop","blazor-server"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}