openapi-backend: TypeError: Converting circular structure to JSON
I’m trying to use a YAML file to create a mock. I’m using example “express-ts-mock” (https://github.com/anttiviljami/openapi-backend/blob/master/examples/express-ts-mock/index.ts)
but this is the result…
snakuzzo@laptop:~/workspace/openapi-backend/examples/express-ts-mock$ npm start
> openapi-backend-express-ts-mock@1.0.0 start /home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock
> node dist/index.js
api listening at http://localhost:9000
(node:90915) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:42:19)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
at stringify (/home/snakuzzo/workspace/openapi-backend/examples/express-ts-mock/node_modules/fast-json-stable-stringify/index.js:50:25)
(node:90915) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:90915) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Any suggestion?
Thanks
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 20 (11 by maintainers)
@snakuzzo I’ve added a PR which should address this problem without re-writing too much of the library. Until it gets merged however, you may be able to solve the problem by using this in your constructor:
where
decycleis a new function which you can find in the PR.And apologies to both of you @elby22 @snakuzzo for the delay with getting back to you. I’ve recently joined a new company, which (I hope) understandably is stretching my available time for OSS maintenance work 😔
@snakuzzo working on a PR now - trying to get it out by today.