You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Algosdk fails parsing JSON from error response when there is no JSON data in the response.
Steps to reproduce
It's difficult to reproduce but I can show you exactly where the problem is.
Expected behaviour
My sandbox is returning a 504 status code from this route algod/v2/transactions/params.
When calling algoClient.getTransactionParams().do() it should print a reasonable error message.
Actual behaviour
Algosdk attempts to parse JSON data from the error response when there is no JSON data resulting in the following unreasonable error message:
SyntaxError: Unexpected token E in JSON at position 0
at JSON.parse (<anonymous>)
at Function.parseJSON (client.ts:125:8)
at Function.prepareResponse (client.ts:187:12)
at Function.prepareResponseError (client.ts:209:33)
at HTTPClient.get (client.js:186:30)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Subject of the issue
Algosdk fails parsing JSON from error response when there is no JSON data in the response.
Steps to reproduce
It's difficult to reproduce but I can show you exactly where the problem is.
Expected behaviour
My sandbox is returning a 504 status code from this route
algod/v2/transactions/params
.When calling
algoClient.getTransactionParams().do()
it should print a reasonable error message.Actual behaviour
Algosdk attempts to parse JSON data from the error response when there is no JSON data resulting in the following unreasonable error message:
The attempt to parse JSON is made here:
js-algorand-sdk/src/client/client.ts
Line 126 in 4478161
The problem originates from this request here:
js-algorand-sdk/src/client/client.ts
Line 233 in 4478161
When the sandbox has a problem (for me it is status 504 at the moment) it throws an error with no JSON in the response which is handled here:
js-algorand-sdk/src/client/client.ts
Line 233 in 4478161
It tries to parse the response from
err.response
which is not JSON so it throws the aforementioned error.The text was updated successfully, but these errors were encountered: