js-algorand-sdk
js-algorand-sdk copied to clipboard
algosdk.Algodv2 overwrites empty port parameter
Subject of the issue
const client = new algosdk.Algodv2("DUMMYTOKEN", "http://127.0.0.1:17458");
Should create a client which will request port 17458, but the client requests port 4180.
it is overwritten here:
https://github.com/algorand/js-algorand-sdk/blob/develop/src/client/v2/algod/algod.ts#L27
Your environment
SDK version 1.12.0, develop branch, ...
Steps to reproduce
- Use an URL with defined non-standard port without
port
parameter - ...
Expected behaviour
It should request a algod on "http://127.0.0.1:17458"
Actual behaviour
it requests "http://127.0.0.1:4180"
If you set the URL to the base URL and pass the port as the third argument it should work.
I know, I have figured it out, I have also figured out where the bug is. And it IS a bug. Or do you think that it is right, that it is secretly overwriting generally accepted standard URL?
We are passing it from "outside", and depends on where our app is running, it may have different forms. So we would need to parse it before instantiating the algod client, set the third argument, then it is passed through several constructors, parsed again and the port will be put back it feels really wrong.
And it is also very confusing that something standard doesn't work.
@tholcman yes I agree the behavior is a bit odd. If you pass an empty string ""
for the port though, I believe it will not get overridden and will work as intended.
We should improve our documentation on this.
:) empty string also tested by a colleague ... and it is even better ... it ended on port :80
but I am not 100% sure about that
Closing in favor of #657