Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Incorrect handling of non-json response from the remote node for HttpProvider #5236

Closed
1 task done
ghost opened this issue Jul 13, 2022 · 0 comments · Fixed by #5228
Closed
1 task done

Incorrect handling of non-json response from the remote node for HttpProvider #5236

ghost opened this issue Jul 13, 2022 · 0 comments · Fixed by #5228
Labels
Bug Addressing a bug

Comments

@ghost
Copy link

ghost commented Jul 13, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Console would warn for unhandled promise rejection when non-json response is received from the remote node, which is a bug.

Expected Behavior

HttpProvider should throw an Invalid JSON RPC response error for non-json response ( Which is usually an error string from the loadbalancer )

Steps to Reproduce

it('should fail for non-json format response', async function () {
            var provider = new HttpProvider('/fetchMock');
            var web3 = new Web3(provider);

            fetchMock.mock('/fetchMock', 'Testing non-json format response');

            await expect(web3.eth.getChainId()).to.be.rejectedWith(Error, /Invalid JSON RPC response/);
            fetchMock.restore();
});

Web3.js Version

1.x

Environment

Fixed by latest commit from PR #5228

Anything Else?

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant