js-algorand-sdk
js-algorand-sdk copied to clipboard
Error when handling http error
Subject of the issue
Somehow we've got an issue when trying to format the error message returned from a post to the transactions endpoint.
The result of a 400 error is the following:
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'TLSSocket'
| property '_httpMessage' -> object with constructor 'ClientRequest'
--- property 'socket' closes the circle
at stringify (<anonymous>)
while trying to handle an error here: https://github.com/algorand/js-algorand-sdk/blob/develop/src/client/urlTokenBaseHTTPClient.ts#L154
Adding a line above the call to format as console.log(err.response.body.toString())
yeilds the expected error message from the algod
Your environment
Same result on js-algorand-sdk 1.15.0 and 1.19.0 node v16.13.1
@barnjamin could you include more of the stack trace? It's unclear to me where that error is originating--we don't stringify any JSON in the urlTokenBaseHTTPClient.ts
file.
@jasonpaulos I wish I could! The above is all that gets printed somehow.
I filed this issue on behalf of someone else I was helping to debug. It may also be downstream from that error like here(https://github.com/algorand/js-algorand-sdk/blob/e16cef3787ce46179745bbd48daccd9fa86045a9/src/client/client.ts#L271) but its very hard to debug
Got it. Do you have any more specifics about the conditions around when this happens? Is it every error type on every endpoint, or something more specific?
This error was happening during a test run using jest
so there may be something else at fault if the request object gets passed all the way back. Waiting on some more details
@barnjamin Have you run into this again?
As is I'm inclined to close this issue since I can't root cause it with the current information here.