Converting circular structure to JSON
See original GitHub issueGetting the below error since may be after the recent feathers lib update.
The error appears randomly at the end of different services.
Error goes away on disabling events (as of now app wide) using context.event = null;
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Timeout'
| property '_idlePrev' -> object with constructor 'TimersList'
--- property '_idleNext' closes the circle
at Object.stringify [as serialize] (<anonymous>)
at Object.emit (/xxx/node_modules/feathers-sync/lib/core.js:47:46)
at /xxx/node_modules/@feathersjs/feathers/lib/events.js:16:42
at Array.forEach (<anonymous>)
at Object.<anonymous> (/xxx/node_modules/@feathersjs/feathers/lib/events.js:16:15)
at /xxx/node_modules/@feathersjs/feathers/node_modules/@feathersjs/commons/lib/hooks.js:115:46
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Module versions (especially the part that’s not working):
"@feathersjs/authentication-client": "^4.3.11",
"@feathersjs/authentication-oauth": "^4.3.11",
"@feathersjs/configuration": "^4.3.11",
"@feathersjs/errors": "^4.3.11",
"@feathersjs/express": "^4.3.11",
"@feathersjs/feathers": "^4.3.11",
"@feathersjs/socketio": "^4.3.11",
"@feathersjs/socketio-client": "^4.3.11",
"feathers-sequelize": "^6.1.0",
"feathers-sync": "^2.0.0",
NodeJS version: v12.13.0
Not sure if my code is triggering this. Unable to understand as the code was working fine earlier.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
What is TypeError: Converting circular structure to JSON?
TypeError: Converting circular structure to JSON occurs when you try to reference your variable name within the JSON object.
Read more >TypeError: Converting circular structure to JSON - Stack ...
TypeError: Converting circular structure to JSON. It seems that I can get the object logged to the console by using just plain: console.log(object)....
Read more >TypeError: Converting circular structure to JSON in JS
The "Converting circular structure to JSON" error occurs when we pass an object that contains circular references to the JSON.stringify() method.
Read more >Converting Circular Structure to JSON - Career Karma
On Career Karma, learn about the restrictions of JSON in the debugging tutorial for converting circular structure to json.
Read more >How to fix TypeError: Converting circular structure to JSON in ...
To fix this error, you need to make sure that your objects don't contain circular references. One way to do this is to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You just have to make sure that none of your data in the context contain a circular reference. A custom serializer is one option to ensure that, another is to make sure that all
params
,result
ordata
properties are serializable or serialized (e.g. with theirtoJSON
methods).I had this issue when I was passing sequelize includes across feathers-sync. A simple fix was to use
flatted
as the serializer as it can serialize objects with circular references.