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

remove params from jsonrpc post payload if empty #70

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

sreuland
Copy link
Contributor

@sreuland sreuland commented Apr 25, 2023

when the jsonrpc.post() method:

export async function post<T>(
  url: string,
  method: string,
  ...params: any
)

is webpacked for browser usage, there's some additional polyfill added to handle the spread params :

function post(url, method) {
    var _a;
    var params = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        params[_i - 2] = arguments[_i];
    }

however, for methods such as getNetwork, getHealth, getLatestLedger that pass no params the result would still include params: [] in the json rpc post, which rpc server rejects with err:

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32602,
        "message": "no parameters accepted"
    }
}

stellar/stellar-cli#458 will depend on this, it uses getLatestLedger

@sreuland sreuland requested a review from paulbellamy April 25, 2023 17:07
Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this PR is good on it's own. However, I'm not sure if the server behavior is correct. Could you please create a ticket to check the soroban-rpc handling in these cases ? ( i.e. we need to align to spec, whatever that would be )

@paulbellamy
Copy link
Contributor

paulbellamy commented Apr 26, 2023

Yeah, seems like a bug in the server.

Edit: This bug in fact: stellar/stellar-rpc#40

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

Successfully merging this pull request may close these issues.

3 participants