Skip to content

Converting circular structure to JSON #24

@rcruz-add

Description

@rcruz-add

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions