dotnet/aspnetcore · error · Error

Invalid payload for Invocation message.

Error message

Invalid payload for Invocation message.

What it means

An Invocation message (type 1) must name the target method in a non-empty string, and if an invocationId is supplied it too must be non-empty. _assertNotEmptyString (line 133) throws this message when target or invocationId is missing, empty, or not a string.

Source

Thrown at src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts:135

        this._assertNotEmptyString(message.invocationId, "Invalid payload for Completion message.");
    }

    private _isAckMessage(message: AckMessage): void {
        if (typeof message.sequenceId !== 'number') {
            throw new Error("Invalid SequenceId for Ack message.");
        }
    }

    private _isSequenceMessage(message: SequenceMessage): void {
        if (typeof message.sequenceId !== 'number') {
            throw new Error("Invalid SequenceId for Sequence message.");
        }
    }

    private _assertNotEmptyString(value: any, errorMessage: string): void {
        if (typeof value !== "string" || value === "") {
            throw new Error(errorMessage);
        }
    }
}

View on GitHub (pinned to 294cab2f9b)

Solutions

  1. Ensure the server always sets a non-empty target method name on every invocation.
  2. Check for a proxy or serializer dropping the target field.
  3. Log the raw message (logMessageContent:true) to confirm target presence.
  4. Confirm client and server use compatible protocol versions.

Example fix

// before
{ "type": 1, "arguments": [1] } // missing target

// after
{ "type": 1, "target": "DoWork", "arguments": [1] }
Defensive patterns

Strategy: validation

Validate before calling

function validInvocation(m: any): boolean {
  return typeof m?.target === 'string' && m.target.length > 0
    && (m.invocationId === undefined || (typeof m.invocationId === 'string' && m.invocationId.length > 0));
}

Type guard

function isInvocationMessage(m: any): m is { type: 1; target: string } {
  return typeof m?.target === 'string' && m.target !== '';
}

Prevention

When it happens

Trigger: Server sends {"type":1,"arguments":[...]} with no target, or an invocationId of "". Also from a custom server that builds invocations with a blank target.

Common situations: Server hub method name resolves to empty, a dynamic-dispatch server forwards a message without setting target, or protocol version mismatch alters the field layout.

Related errors


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