TypeError: Converting Circular structure to JSON
See original GitHub issueSo I’m attempting to delete a row inside my psql database, a very simple structure with 4 rows + the auto ID:
CREATE TABLE public.tags
(
id bigint NOT NULL DEFAULT nextval('tags_id_seq'::regclass),
tag character varying(32) NOT NULL,
description character varying(256) NOT NULL,
server character(18) NOT NULL,
added_by character(18) NOT NULL,
CONSTRAINT tags_pkey PRIMARY KEY (id)
)
Attempting to reproduce the .del()
example, I have the following code: knex('tags').where('tag', 'test').del();
I get the following error output to me: TypeError: Converting circular structure to JSON
I’m unsure what could cause this, and how to resolve it. Any ideas?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 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 ...
It means that the object you pass in the request (I guess it is pagedoc ) has a circular reference, something like: var...
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. To solve...
Read more >Converting Circular Structure to JSON - Career Karma
JSON does not support object references, so trying to stringify a JSON object that references itself will result in a typeerror. It is...
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 Free
Top 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
So this is what I’m guessing might be a similar problem to #1522, the async behavior isn’t kicked off unless the query is executed w/
then
or similar.If you put
.then()
on the end of the.del()
it will executed the promise:The
TypeError: Converting circular structure to JSON
shows up when you trying toJSON.stringify
something which has a reference to itsself, which is probably happening whenJSON.stringify
a query building chain that hasn’t been executed, rather than its return result from the promise or callback.@eslachance I didn’t have that issue, because I didn’t ran the query, just checked what kind of SQL generates from it.
I still have no idea where in the code you are trying to convert object with circular dependencies to json string 😃 Great that you got your problem solved!
Functionality how queries are triggered is described in:
http://knexjs.org/#Builder http://knexjs.org/#Interfaces-Promises http://knexjs.org/#Interfaces-Callbacks http://knexjs.org/#Interfaces-Streams
pull requests to improve documentation are always welcome!