Skip to content

Notification for non-existent method will elicit response which is non-standard #6

Open
@8749236

Description

@8749236

According to JSON RPC 2.0 Section 4.1

Notifications are not confirmable by definition, since they do not have a Response object to be returned. As such, the Client would not be aware of any errors (like e.g. "Invalid params","Internal error").

Sample communication:

{"jsonrpc":"2.0","method":"SetWindowLocked","params":[false]}
{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found. The method does not exist / is not available.","data":"SetWindowLocked"}}
{"jsonrpc":"2.0","method":"SetClickthrough","params":[false]}
{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found. The method does not exist / is not available.","data":"SetClickthrough"}}
{"jsonrpc":"2.0","method":"SetVisible","params":[false]}
{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found. The method does not exist / is not available.","data":"SetVisible"}}

Proposed solution:
In handleRemoteRequest method, change else block into

            else if (request.hasOwnProperty('id')) {
                return _Promise.resolve({
                    "jsonrpc": "2.0",
                    "id": request.id,
                    "error": setError(ERRORS.METHOD_NOT_FOUND, {
                        message: request.method
                    })
                });
            }
            else {
                // Don't return method not found for notifications
                console.warn("Received notification for non-existent method:", request.method);
                return _Promise.resolve();
            }

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