You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the "Converting circular structure to JSON" error in my project, and I know it happens in one of my "res.send"s. But it doesn't happen every time the API is called, as I sometimes see it in my logs. The server is in production mode and there is no report about it from users.
Environment
Inversify Version: 6.0.1
Node.js 18.16.1
Operating System and version: Ubuntu 22.04.2 LTS
Stack trace
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ServerResponse'
| property 'socket' -> object with constructor 'Socket'
--- property '_httpMessage' closes the circle
at JSON.stringify ()
at stringify (/home/lineage/workspace/posterity-refactored-backend/node_modules/express/lib/response.js:1150:12)
at ServerResponse.json (/home/lineage/workspace/posterity-refactored-backend/node_modules/express/lib/response.js:271:14)
at ServerResponse.send (/home/lineage/workspace/posterity-refactored-backend/node_modules/express/lib/response.js:162:21)
at InversifyExpressServer. (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/src/server.ts:273:25)
at step (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/lib/server.js:33:23)
at Object.next (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/lib/server.js:14:53)
at fulfilled (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/lib/server.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
The text was updated successfully, but these errors were encountered:
Based on my observation, the problem arises when the server's response is sent after connection is dropped and return res.sendStatus() syntax is used. In my case, I was able to resolve the issue by modifying the code as follows.
I get the "Converting circular structure to JSON" error in my project, and I know it happens in one of my "res.send"s. But it doesn't happen every time the API is called, as I sometimes see it in my logs. The server is in production mode and there is no report about it from users.
Environment
Stack trace
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ServerResponse'
| property 'socket' -> object with constructor 'Socket'
--- property '_httpMessage' closes the circle
at JSON.stringify ()
at stringify (/home/lineage/workspace/posterity-refactored-backend/node_modules/express/lib/response.js:1150:12)
at ServerResponse.json (/home/lineage/workspace/posterity-refactored-backend/node_modules/express/lib/response.js:271:14)
at ServerResponse.send (/home/lineage/workspace/posterity-refactored-backend/node_modules/express/lib/response.js:162:21)
at InversifyExpressServer. (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/src/server.ts:273:25)
at step (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/lib/server.js:33:23)
at Object.next (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/lib/server.js:14:53)
at fulfilled (/home/lineage/workspace/posterity-refactored-backend/node_modules/inversify-express-utils/lib/server.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
The text was updated successfully, but these errors were encountered: