{"record":{"id":"4bedeae609815013","repo":"dotnet/aspnetcore","slug":"invalid-payload-for-completion-message","errorCode":null,"errorMessage":"Invalid payload for Completion message.","messagePattern":"Invalid payload for Completion message\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts","lineNumber":232,"sourceCode":"\n    private _createStreamItemMessage(headers: MessageHeaders, properties: any[]): StreamItemMessage {\n        // check minimum length to allow protocol to add items to the end of objects in future releases\n        if (properties.length < 4) {\n            throw new Error(\"Invalid payload for StreamItem message.\");\n        }\n\n        return {\n            headers,\n            invocationId: properties[2],\n            item: properties[3],\n            type: MessageType.StreamItem,\n        } as StreamItemMessage;\n    }\n\n    private _createCompletionMessage(headers: MessageHeaders, properties: any[]): CompletionMessage {\n        // check minimum length to allow protocol to add items to the end of objects in future releases\n        if (properties.length < 4) {\n            throw new Error(\"Invalid payload for Completion message.\");\n        }\n\n        const resultKind = properties[3];\n\n        if (resultKind !== this._voidResult && properties.length < 5) {\n            throw new Error(\"Invalid payload for Completion message.\");\n        }\n\n        let error: string | undefined;\n        let result: any;\n\n        switch (resultKind) {\n            case this._errorResult:\n                error = properties[4];\n                break;\n            case this._nonVoidResult:\n                result = properties[4];\n                break;","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts#L214-L250","documentation":"Thrown by _createCompletionMessage when the decoded properties array has fewer than 4 elements. A Completion frame is [MessageType.Completion, headers, invocationId, resultKind, ...] so it needs at least the type, headers, invocationId, and resultKind. This guard fires before resultKind is inspected.","triggerScenarios":"Server sends a Completion frame missing the resultKind (properties[3]); frame corruption removes trailing elements; protocol version mismatch.","commonSituations":"Version skew; a server-side hub method returns and the Completion frame is serialized without the resultKind byte; network truncation.","solutions":["Align SignalR client and server versions.","Verify the server isn't a custom/non-ASP.NET implementation producing non-standard Completion frames.","Catch and treat as a failed invocation; surface the error to the caller of connection.invoke.","Inspect server logs for the completing hub method."],"exampleFix":"// before\nconst result = await connection.invoke('DoWork');\n// server sends short Completion -> throws\n\n// after\ntry {\n  const result = await connection.invoke('DoWork');\n} catch (e) {\n  logger.log(LogLevel.Error, 'Invoke failed (possibly malformed Completion): ' + e.message);\n  await reconnect();\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await connection.invoke('DoWork');\n} catch (e) {\n  if (/Completion message/.test(e?.message)) {\n    logger.log(LogLevel.Error, 'Malformed Completion frame; reconnecting.');\n    await connection.start();\n  } else throw e;\n}","preventionTips":["Align client/server SignalR versions so Completion frames carry the expected fields.","Wrap connection.invoke calls in try/catch and surface/handle malformed-frame errors.","Inspect server logs for the completing hub method when this recurs."],"tags":["messagepack","completion-message","validation","parsing","version-skew"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}