Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
8749236 opened this issue Jul 19, 2022 · 0 comments

Comments

@8749236
Copy link

8749236 commented Jul 19, 2022

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();
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant