{"record":{"id":"6ec95580488c9718","repo":"dotnet/aspnetcore","slug":"received-persisted-state-for-circuit-id-circuit","errorCode":null,"errorMessage":"Received persisted state for circuit ID '${circuitId}', but the current circuit ID is '${this._circuitId}'.","messagePattern":"Received persisted state for circuit ID '(.+?)', but the current circuit ID is '(.+?)'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts","lineNumber":169,"sourceCode":"        this.changeActivity(1);\n      }\n      (this._dispatcher.beginInvokeJSFromDotNet as (...a: unknown[]) => unknown)\n        .call(this._dispatcher, asyncHandle, ...rest);\n    });\n    connection.on('JS.EndInvokeDotNet', (asyncCallId: string, success: boolean, resultJsonOrExceptionMessage: string) => {\n      if (asyncCallId) {\n        this.changeActivity(-1);\n      }\n      this._dispatcher.endInvokeDotNetFromJS(asyncCallId, success, resultJsonOrExceptionMessage);\n    });\n    connection.on('JS.ReceiveByteArray', this._dispatcher.receiveByteArray.bind(this._dispatcher));\n\n    connection.on('JS.SavePersistedState', (circuitId: string, components: string, applicationState: string) => {\n      if (!this._circuitId) {\n        throw new Error('Circuit host not initialized.');\n      }\n      if (circuitId !== this._circuitId) {\n        throw new Error(`Received persisted state for circuit ID '${circuitId}', but the current circuit ID is '${this._circuitId}'.`);\n      }\n      this._persistedCircuitState = { components, applicationState };\n      return true;\n    });\n\n    connection.on('JS.BeginTransmitStream', (streamId: number) => {\n      const readableStream = new ReadableStream({\n        start: (controller) => {\n          this.changeActivity(1);\n          connection.stream('SendDotNetStreamToJS', streamId).subscribe({\n            next: (chunk: Uint8Array) => controller.enqueue(chunk),\n            complete: () => { controller.close(); this.changeActivity(-1); },\n            error: (err) => { controller.error(err); this.changeActivity(-1); },\n          });\n        },\n      });\n\n      this._dispatcher.supplyDotNetStream(streamId, readableStream);","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts#L151-L187","documentation":"Thrown in the 'JS.SavePersistedState' handler when the circuitId the server references does not equal the client's current _circuitId. Persisted state is circuit-scoped, so accepting it for a different circuit would corrupt state; the client refuses the mismatch.","triggerScenarios":"A reconnection/restart assigned a new circuitId while a SavePersistedState message for the old circuit was still in flight; concurrent or racing circuit handshakes; server-side circuit reuse/rotation during a paused session.","commonSituations":"Unstable networks causing multiple rapid reconnects; tab freeze/thaw triggering pause-resume where the server rotated the circuit; version skew between client and server persistence protocols.","solutions":["Stabilize the connection (network, proxy, WebSocket availability) so only one circuit lifecycle is active.","Match client and server framework versions to keep the persisted-state protocol consistent.","Avoid programmatically forcing reconnects in parallel with an in-flight resume; let the framework serialize them."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The framework throws internally; surface a clean reconnect UI.\ntry { await circuitManager.resume(); }\ncatch (e) {\n  if (/current circuit ID/i.test(e.message)) {\n    showReconnectUI(); // prompt reload\n  } else throw e;\n}","preventionTips":["Stabilize the WebSocket connection to avoid racing reconnects.","Do not run multiple reconnect attempts in parallel.","Keep client/server versions in sync."],"tags":["blazor-server","circuit","state-persistence","signalr"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}