dotnet/aspnetcore · error · Error
Invalid payload for Completion message.
Error message
Invalid payload for Completion message.
What it means
Thrown by _createCompletionMessage (first check) when the decoded properties array has fewer than 4 elements. A Completion message is [MessageType.Completion, headers, invocationId, resultKind, result?]. resultKind (properties[3]) is mandatory — fewer than 4 elements means the result kind is absent.
Solutions
- Verify the server's completion encoder includes the resultKind slot.
- Match SignalR protocol versions between client and server.
- Reconnect the HubConnection; the invocation whose completion was malformed will not resolve, so callers awaiting it should also be notified.
Example fix
// before
// server emits [3, {}, '42'] — missing resultKind → throws
// after — server must emit [3, {}, '42', resultKind, ...]
// e.g. void result: [3, {}, '42', 0] Defensive patterns
Strategy: validation
Validate before calling
function isValidCompletionProperties(p: unknown[]): boolean {
return p.length >= 4;
} Type guard
function isCompletionPayload(p: unknown[]): p is [number, unknown, string, number, unknown?] {
return p.length >= 4;
} Try / catch
try { return protocol.parseMessages(buf, logger); }
catch (e) {
if (/Invalid payload for Completion/.test((e as Error).message)) {
logger.log(LogLevel.Error, 'Malformed Completion — reconnecting');
await connection.stop(); await connection.start();
} else throw e;
} Prevention
- Server must always emit the resultKind slot for completions.
- Align client/server SignalR protocol versions.
- Notify awaiting callers when a completion cannot be parsed.
When it happens
Trigger: A Completion frame missing the resultKind byte; corrupt bytes decoding to a short array typed as Completion; a non-conforming server sending an incompletely-encoded completion.
Common situations: Server-side completion serialization bug; protocol version mismatch; wire corruption after an invocation.
Related errors
- Invalid payload for Close message.
- Invalid payload for Invocation message.
- Invalid payload.
- Invalid payload for Ping message.
- Invalid payload for StreamItem message.
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/4bedeae609815013.
Report an issue: GitHub.
Appendix: source
Thrown at src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts:232
private _createStreamItemMessage(headers: MessageHeaders, properties: any[]): StreamItemMessage {
// check minimum length to allow protocol to add items to the end of objects in future releases
if (properties.length < 4) {
throw new Error("Invalid payload for StreamItem message.");
}
return {
headers,
invocationId: properties[2],
item: properties[3],
type: MessageType.StreamItem,
} as StreamItemMessage;
}
private _createCompletionMessage(headers: MessageHeaders, properties: any[]): CompletionMessage {
// check minimum length to allow protocol to add items to the end of objects in future releases
if (properties.length < 4) {
throw new Error("Invalid payload for Completion message.");
}
const resultKind = properties[3];
if (resultKind !== this._voidResult && properties.length < 5) {
throw new Error("Invalid payload for Completion message.");
}
let error: string | undefined;
let result: any;
switch (resultKind) {
case this._errorResult:
error = properties[4];
break;
case this._nonVoidResult:
result = properties[4];
break;View on GitHub (pinned to 3600ca084e)