AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
237 stars 20 forks source link

TypeError: Converting circular structure to JSON #139

Closed nimatrueway closed 2 years ago

nimatrueway commented 2 years ago

I ran a simple rest-call, succeeded. The 2nd time I tried to run the same request (onwards) I get this error:

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'httpRegions' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'Object'
    |     ...
    |     index 0 -> object with constructor 'Object'
    --- property 'httpFile' closes the circle
    at JSON.stringify (<anonymous>)
    at vke (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:305:13451)
    at Object.logMethod (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:305:12981)
    at s (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:157:2714)
    at u$.writeLog (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:157:2775)
    at u$.error (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:157:3008)
    at ts (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:305:9185)
    at I$ (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:305:16159)
    at hj.<anonymous> (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:305:19762)
    at Generator.next (<anonymous>)
    at s (/Users/nima.taheri/.vscode/extensions/anweber.vscode-httpyac-5.5.5/dist/extension.js:1:1652)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Basically I'll have to restart vs-code after each request. I downgraded to 5.5.4 and things are working as expected. This issue is only happening on 5.5.5.

Looks like a case where JSON.stringify has been invoked on an httpFile.httpRegions[0]...httpFile object.

I can dig into it and provide more details if this doesn't give a cue on the root cause.

AnWeber commented 2 years ago

root cause should be this commit: https://github.com/AnWeber/vscode-httpyac/commit/bccc4b8389a16cd6fe9977df5ca2a0d645b911de. Actually I wanted to prevent exactly this problem by using the inspect method from node:utils. I have now changed it to a variant cribbed from MDN.