dotnet/aspnetcore · 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 [MessageType.StreamItem, headers, invocationId, item], so four is the minimum. This fires when a streaming result frame is missing its invocationId or item slot.
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 294cab2f9b)
Solutions
- Confirm client and server SignalR versions match, especially for streaming scenarios.
- Check that server-side streaming methods (IAsyncEnumerable / Channel) complete cleanly.
- Catch the error and end the affected stream subscription / reconnect.
- Inspect the failing hub method for exceptions during enumeration.
Example fix
// before
connection.stream('StreamData').subscribe({ next: x => {} });
// server emits short StreamItem -> throws inside parseMessages
// after
connection.stream('StreamData').subscribe({
next: x => {},
error: err => logger.log(LogLevel.Error, 'Stream failed: ' + err),
}); Defensive patterns
Strategy: try-catch
Try / catch
const subscription = connection.stream('StreamData').subscribe({
next: x => handleItem(x),
error: err => {
if (/StreamItem message/.test(err?.message)) {
logger.log(LogLevel.Error, 'Malformed StreamItem; resubscribing.');
reconnect();
}
},
}); Prevention
- Always provide an error handler to connection.stream(...).subscribe().
- Keep streaming implementations on both ends at compatible SignalR versions.
- Ensure server-side streaming methods (Channel / IAsyncEnumerable) don't throw mid-enumeration producing malformed frames.
When it happens
Trigger: Server sends a StreamItem frame missing the item element; corruption strips trailing bytes of a streaming result; the server is an older/newer version using a different StreamItem layout.
Common situations: Version mismatch between client and server streaming implementation; a server-side streaming hub method throwing mid-stream producing a malformed frame; network truncation of a large streamed item.
Related errors
- Invalid payload for Close message.
- Invalid payload for Ping message.
- Invalid payload for Invocation message.
- Invalid payload for Completion message.
- Invalid payload for Ack message.
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/97a24669f9422bef.
Report an issue: GitHub.