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

A result of 'false' is converted to '{}' #11

Open
0xJMR opened this issue Mar 18, 2019 · 1 comment
Open

A result of 'false' is converted to '{}' #11

0xJMR opened this issue Mar 18, 2019 · 1 comment

Comments

@0xJMR
Copy link

0xJMR commented Mar 18, 2019

First of all, I must thank you for this project. As of this writing, I struggled to find a JSON-RPC implementation which is transport-agnostic, works out of the box with TypeScript, and makes use of ECMAScript 6 Proxy objects in order to abstract from the actual communication.

Overall, I did not encounter any problems except for the following one. Let us assume that you have a remote object with a method isReadable which returns true if a document is readable and false otherwise. Furthermore, let us assume that the method is executed on a document which is not readable. The remote call of this method would therefore return false and the expected result for the local method call would therefore also be false. However, instead one receives {} as result.

The problem lies within the lines 261 and 267 of noice-json-rpc.ts. The shortcut result || {} used to give undefined results a default value will also evaluate to {} for false as result and this might be unwanted behavior. Replacing this part with something like result === undefined ? {} : result should fix this issue.

@nojvek
Copy link
Owner

nojvek commented Oct 29, 2019

Thanks for the catch. Will look into it.

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

2 participants