{"record":{"id":"948d3cb133103d97","repo":"dotnet/aspnetcore","slug":"invalid-sequenceid-for-sequence-message","errorCode":null,"errorMessage":"Invalid SequenceId for Sequence message.","messagePattern":"Invalid SequenceId for Sequence message\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts","lineNumber":129,"sourceCode":"            throw new Error(\"Invalid payload for Completion message.\");\n        }\n\n        if (!message.result && message.error) {\n            this._assertNotEmptyString(message.error, \"Invalid payload for Completion message.\");\n        }\n\n        this._assertNotEmptyString(message.invocationId, \"Invalid payload for Completion message.\");\n    }\n\n    private _isAckMessage(message: AckMessage): void {\n        if (typeof message.sequenceId !== 'number') {\n            throw new Error(\"Invalid SequenceId for Ack message.\");\n        }\n    }\n\n    private _isSequenceMessage(message: SequenceMessage): void {\n        if (typeof message.sequenceId !== 'number') {\n            throw new Error(\"Invalid SequenceId for Sequence message.\");\n        }\n    }\n\n    private _assertNotEmptyString(value: any, errorMessage: string): void {\n        if (typeof value !== \"string\" || value === \"\") {\n            throw new Error(errorMessage);\n        }\n    }\n}\n","sourceCodeStart":111,"sourceCodeEnd":139,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/92f07e298d5c5a629385b8b0a32d7164b1b53906/src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts#L111-L139","documentation":"Thrown by JsonHubProtocol._isSequenceMessage() when a Sequence message's 'sequenceId' field is not a number. Sequence messages are part of the stateful-reconnect flow and carry an integer sequenceId used to resynchronize the message stream after reconnect. A non-numeric value indicates a malformed Sequence message.","triggerScenarios":"Server sends a Sequence message with a missing, null, or string sequenceId. Happens with stateful reconnect enabled but a protocol mismatch or corrupted frame.","commonSituations":"Client/server version skew on the stateful-reconnect protocol; a proxy altering the body; reconnect resync logic disagreement.","solutions":["Confirm client and server both support and agree on the stateful reconnect protocol.","Match protocol versions on both ends.","Capture the Sequence payload with trace logging.","Disable withStatefulReconnect if not required by the server to avoid Sequence messages."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasNumericSequenceId(m: any): boolean {\n  return m != null && typeof m.sequenceId === 'number';\n}","tryCatchPattern":"conn.onclose((err) => {\n  if (err instanceof Error && err.message === 'Invalid SequenceId for Sequence message.') {\n    console.error('Malformed Sequence in stateful-reconnect flow; verify server support', err);\n  }\n});","preventionTips":["Keep client and server stateful-reconnect support aligned.","Verify protocol versions match.","Disable withStatefulReconnect when not required by the server."],"tags":["protocol","json","reconnect","message-parsing","typescript"],"analyzedSha":"92f07e298d5c5a629385b8b0a32d7164b1b53906","analyzedAt":"2026-08-07T06:05:17.747Z","schemaVersion":2},"datasetVersion":"2026-08-07T15:17:06.553Z"}