{"record":{"id":"a47bdbd021f637b9","repo":"dotnet/aspnetcore","slug":"invalid-sequenceid-for-ack-message","errorCode":null,"errorMessage":"Invalid SequenceId for Ack message.","messagePattern":"Invalid SequenceId for Ack message\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts","lineNumber":123,"sourceCode":"            throw new Error(\"Invalid payload for StreamItem message.\");\n        }\n    }\n\n    private _isCompletionMessage(message: CompletionMessage): void {\n        if (message.result && message.error) {\n            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":105,"sourceCodeEnd":139,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts#L105-L139","documentation":"Thrown by JsonHubProtocol._isAckMessage when an Ack message's `sequenceId` is not of type `number`. Ack messages (part of the stateful-reconnect / sequence-id protocol extension) must carry a numeric sequenceId so the peer can acknowledge the highest contiguous message received.","triggerScenarios":"Receiving a JSON message with `type` corresponding to Ack but whose `sequenceId` is missing, a string, null, or any non-number value. This typically originates from a malformed server response or a protocol-extension version mismatch.","commonSituations":"Enabling stateful reconnect on the client while the server runs a version that does not support it (or vice versa), or a proxy/gateway corrupting the sequenceId field.","solutions":["Confirm both client and server support the stateful-reconnect (sequence/Ack) protocol extension.","Inspect the Ack frame to verify sequenceId is present and numeric.","If a gateway is in the path, ensure it does not rewrite or drop numeric fields."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"function validAck(m: any): boolean {\n  return typeof m?.sequenceId === \"number\";\n}","typeGuard":"function isNumericSequenceId(m: any): m is { sequenceId: number } {\n  return !!m && typeof m.sequenceId === \"number\" && Number.isFinite(m.sequenceId);\n}","tryCatchPattern":null,"preventionTips":["Enable stateful reconnect on both client and server.","Ensure gateways do not rewrite the sequenceId field.","Validate Ack frames during integration testing."],"tags":["protocol","json","sequence","stateful-reconnect","parsing"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}