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 #24

Open
rcruz-add opened this issue Sep 7, 2022 · 1 comment
Open

Converting circular structure to JSON #24

rcruz-add opened this issue Sep 7, 2022 · 1 comment

Comments

@rcruz-add
Copy link

Hi,
I need to get body and headers from response. So, I put:

httpClient: {
logging: true,
responseFormatter: "raw",
errorFormatter: httpError,
},

But, in this format is creating a circular reference, causing an error in json serializer:
"Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property '_httpMessage' -> object with constructor 'ClientRequest' --- property 'socket' closes the circle"

"TypeError: Converting circular structure to JSON
--> starting at object with constructor 'TLSSocket'
| property '_httpMessage' -> object with constructor 'ClientRequest'
--- property 'socket' closes the circle
at JSON.stringify ()
at JSONSerializer.serialize (.../add-tools-http-api/node_modules/moleculer/src/serializers/json.js:35:27)
at RedisTransporter.serialize (.../add-tools-http-api/node_modules/moleculer/src/transporters/base.js:347:33)
at RedisTransporter.publish (.../add-tools-http-api/node_modules/moleculer/src/transporters/base.js:190:21)
at RedisTransporter.prepublish (.../add-tools-http-api/node_modules/moleculer/src/transporters/base.js:333:15)
at Transit.publish (.../add-tools-http-api/node_modules/moleculer/src/transit.js:1372:18)
at Transit.sendResponse (.../add-tools-http-api/node_modules/moleculer/src/transit.js:1166:15)
at .../add-tools-http-api/node_modules/moleculer/src/transit.js:507:23
at processTicksAndRejections (node:internal/process/task_queues:96:5)"

Thanks for any help

@AndreMaz
Copy link
Member

AndreMaz commented Oct 9, 2022

Hi @rcruz-add

This is expected behavior. The raw option returns got's request object, which is not serializable so that's why you get the circular structure error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants