dotnet/aspnetcore · error · RuntimeException

Invalid invocation result kind.

Error message

Invalid invocation result kind.

What it means

A CompletionMessage carries a resultKind of 1 (error), 2 (void), or 3 (non-void). If the unpacker reads any other integer for resultKind, the completion is malformed and cannot be interpreted, so parsing throws.

Source

Thrown at src/SignalR/clients/java/signalr/messagepack/src/main/java/com/microsoft/signalr/messagepack/MessagePackHubProtocol.java:260

        Map<String, String> headers = readHeaders(unpacker);
        String invocationId = unpacker.unpackString();
        int resultKind = unpacker.unpackInt();

        String error = null;
        Object result = null;

        switch (resultKind) {
            case ERROR_RESULT:
                error = unpacker.unpackString();
                break;
            case VOID_RESULT:
                break;
            case NON_VOID_RESULT:
                Type itemType = binder.getReturnType(invocationId);
                result = readValue(unpacker, itemType, payload, true);
                break;
            default:
                throw new RuntimeException("Invalid invocation result kind.");
        }

        return new CompletionMessage(headers, invocationId, result, error);
    }

    private HubMessage createStreamInvocationMessage(MessageUnpacker unpacker, InvocationBinder binder, int itemCount, ByteBuffer payload) throws IOException {
        Map<String, String> headers = readHeaders(unpacker);
        String invocationId = unpacker.unpackString();
        String target = unpacker.unpackString();

        Object[] arguments = null;
        try {
            List<Type> types = binder.getParameterTypes(target);
            arguments = bindArguments(unpacker, types, payload);
        } catch (Exception ex) {
            return new InvocationBindingFailureMessage(invocationId, target, ex);
        }

View on GitHub (pinned to 294cab2f9b)

Solutions

  1. Use a matching SignalR server and client version.
  2. Validate that no proxy corrupts framing upstream.
  3. If streaming/invoke results fail consistently, capture the completion frame bytes.
Defensive patterns

Strategy: try-catch

Try / catch

// Java
hubConnection.invoke(new TypeReference<Result>(){}, "Method").subscribe(
    ok -> {},
    err -> {
        if (err.getMessage() != null && err.getMessage().contains("result kind")) {
        }
    });

Prevention

When it happens

Trigger: Server sends a CompletionMessage with a resultKind outside {1,2,3}; buffer misalignment that causes the wrong byte to be read as resultKind; protocol version mismatch.

Common situations: Server/client SignalR version mismatch; non-conformant server; upstream framing corruption shifting byte alignment.

Related errors


AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06). Data as JSON: /api/errors/93492921ab3fe9b6. Report an issue: GitHub.