Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting circular structure to JSON error with ts-node upgrade #115

Open
nagarakesh4 opened this issue Sep 8, 2022 · 3 comments
Open
Labels
bug Something isn't working

Comments

@nagarakesh4
Copy link

Describe the bug
After upgrading ts-node to 10.8.1 , there is an error reported by axios logger . The error is not seen while on earlier versions of ts-node.

Versions
TS-Node: 10.8.1
Axios Logger: 2.6.1

Error Message
Converting circular structure to JSON with ts-node upgrade

Error Stack
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'TLSSocket'
| property 'parser' -> object with constructor 'HTTPParser'
--- property 'socket' closes the circle
at JSON.stringify ()
at StringBuilder.makeData (/node_modules/axios-logger/src/common/string-builder.ts:67:9)
at responseLogger (/node_modules/axios-logger/src/logger/response.ts:20:10)

@nagarakesh4 nagarakesh4 changed the title Converting circular structure to JSON with ts-node upgrade Converting circular structure to JSON error with ts-node upgrade Sep 8, 2022
@arteme
Copy link

arteme commented Sep 9, 2022

@nagarakesh4 what is the version of ts-node you used previously? I have the same error with ts-node 10.4.0, in my case, specifically with responseType: 'stream'

@arteme
Copy link

arteme commented Sep 9, 2022

Looks like the StringBuilder class does not differentiate between different payload types. Anything that is not a string it tries to jsonify. I worked around my specific case using this:

        this.http.interceptors.request.use(AxiosLogger.requestLogger);
        this.http.interceptors.response.use((res) => {
            let data;
            if (res.data instanceof IncomingMessage) {
                data = res.data;
                res.data = '<IncomingMessage>';
            }
            AxiosLogger.responseLogger(res);
            if (data) {
                res.data = data;
            }
            return res;
        });

@hg-pyun hg-pyun added the bug Something isn't working label Sep 11, 2022
@hg-pyun
Copy link
Owner

hg-pyun commented Sep 11, 2022

I think we should proceed with the test on that node version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants