Skip to content

Relax type checking of JSON-RPC responses #958

Closed
@jcubic

Description

@jcubic

Discussed in #957

Originally posted by garrylie August 6, 2024
I got this error each time I send a command:

[AJAX] Invalid JSON-RPC - Server responded:
{"id":"1","result":"pong","jsonrpc":"2.0"}

What is wrong with my response?
content-type is application/json.

The error is that "id" field is a string, not a number.

This is the function that check the type:

function validJSONRPC(response) {
    return typeof response.id === 'number' &&
        (typeof response.result !== 'undefined' ||
         typeof response.error !== 'undefined');
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions