dotnet/aspnetcore · error · Error
Invalid payload for StreamItem message.
Error message
Invalid payload for StreamItem message.
What it means
Thrown by _createStreamItemMessage when the decoded properties array has fewer than 4 elements. A StreamItem is encoded as [MessageType.StreamItem, headers, invocationId, item]. Fewer than 4 means the item slot — the actual streamed value — is missing.
Solutions
- Confirm the server's streaming hub method emits items correctly with the canonical MessagePack encoder.
- Match server and client SignalR protocol versions.
- Reconnect: a malformed stream item invalidates the stream and likely the connection.
Example fix
// before
// server stream emits [2, {}, '42'] — missing item → throws
// after — server must emit [2, {}, '42', itemValue] Defensive patterns
Strategy: validation
Validate before calling
function isValidStreamItemProperties(p: unknown[]): boolean {
return p.length >= 4;
} Type guard
function isStreamItemPayload(p: unknown[]): p is [number, unknown, string, unknown] {
return p.length >= 4;
} Try / catch
try { return protocol.parseMessages(buf, logger); }
catch (e) {
if (/Invalid payload for StreamItem/.test((e as Error).message)) {
logger.log(LogLevel.Error, 'Malformed StreamItem — reconnecting');
await connection.stop(); await connection.start();
} else throw e;
} Prevention
- Confirm the server's streaming implementation emits the item slot.
- Match SignalR protocol versions.
- Reconnect on stream-item corruption.
When it happens
Trigger: Receiving a StreamItem frame missing the item slot; corrupt bytes decoded to a short array typed as StreamItem; a non-conforming server-side streaming implementation.
Common situations: Server-side streaming bug that emits the headers/id without the item; protocol version drift; wire corruption mid-stream.
Related errors
- Invalid payload.
- Invalid payload for Close message.
- Invalid payload for Completion message.
- Invalid payload for Invocation message.
- Invalid payload for Ping message.
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/97a24669f9422bef.
Report an issue: GitHub.
Appendix: source
Thrown at src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts:218
target: properties[3] as string,
type: MessageType.Invocation,
};
} else {
return {
arguments: properties[4],
headers,
streamIds: [],
target: properties[3],
type: MessageType.Invocation,
};
}
}
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];
View on GitHub (pinned to 3600ca084e)