dotnet/aspnetcore · error · Error

Invalid SequenceId for Sequence message.

Error message

Invalid SequenceId for Sequence message.

What it means

Thrown by JsonHubProtocol._isSequenceMessage when a Sequence message's `sequenceId` is not of type `number`. Sequence messages tell the receiver how many messages to expect before an Ack; a non-numeric sequenceId cannot be honored and is rejected.

Solutions

  1. Match the stateful-reconnect extension version between client and server.
  2. Verify the Sequence frame includes a numeric sequenceId before transmission.
  3. Remove any middleware that re-encodes numeric fields as strings.
Defensive patterns

Strategy: type-guard

Validate before calling

function validSequence(m: any): boolean {
  return typeof m?.sequenceId === "number";
}

Type guard

function isNumericSequenceId(m: any): m is { sequenceId: number } {
  return !!m && typeof m.sequenceId === "number" && Number.isFinite(m.sequenceId);
}

Prevention

When it happens

Trigger: Receiving a JSON message with `type` corresponding to Sequence but `sequenceId` is missing, a string, null, or otherwise non-number. Typically caused by a malformed or version-mismatched server frame in a stateful-reconnect session.

Common situations: Stateful reconnect enabled on one peer only, a server implementation that emits sequenceId as a string, or a proxy that alters the field.

Related errors


AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11). Data as JSON: /api/errors/948d3cb133103d97. Report an issue: GitHub.

Appendix: source

Thrown at src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts:129

            throw new Error("Invalid payload for Completion message.");
        }

        if (!message.result && message.error) {
            this._assertNotEmptyString(message.error, "Invalid payload for Completion message.");
        }

        this._assertNotEmptyString(message.invocationId, "Invalid payload for Completion message.");
    }

    private _isAckMessage(message: AckMessage): void {
        if (typeof message.sequenceId !== 'number') {
            throw new Error("Invalid SequenceId for Ack message.");
        }
    }

    private _isSequenceMessage(message: SequenceMessage): void {
        if (typeof message.sequenceId !== 'number') {
            throw new Error("Invalid SequenceId for Sequence message.");
        }
    }

    private _assertNotEmptyString(value: any, errorMessage: string): void {
        if (typeof value !== "string" || value === "") {
            throw new Error(errorMessage);
        }
    }
}

View on GitHub (pinned to 3600ca084e)