Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[type] assert cannot convert circular structure to json #505

Open
marcus-sa opened this issue Nov 10, 2023 · 0 comments
Open

[type] assert cannot convert circular structure to json #505

marcus-sa opened this issue Nov 10, 2023 · 0 comments

Comments

@marcus-sa
Copy link
Contributor

marcus-sa commented Nov 10, 2023

Test can be found here https://github.com/marcus-sa/ngkit/blob/be76fee58879546d42d3a33ab8afe3a4055a1a7a/packages/core/src/lib/router/process.spec.ts#L78-L84

Error: Uncaught (in promise): TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'RouterStateSnapshot'
    |     property '_root' -> object with constructor 'TreeNode'
    |     property 'value' -> object with constructor 'ActivatedRouteSnapshot'
    --- property '_routerState' closes the circle
TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'RouterStateSnapshot'
    |     property '_root' -> object with constructor 'TreeNode'
    |     property 'value' -> object with constructor 'ActivatedRouteSnapshot'
    --- property '_routerState' closes the circle
    at JSON.stringify (<anonymous>)
    at ValidationErrorItem.toString (/Users/marcus-sa/Git/deepkit/deepkit-framework/packages/type/src/validator.ts:97:40)
    at /Users/marcus-sa/Git/deepkit/deepkit-framework/packages/type/src/validator.ts:112:104
    at Array.map (<anonymous>)
    at new ValidationError (/Users/marcus-sa/Git/deepkit/deepkit-framework/packages/type/src/validator.ts:112:93)
    at Module.assert (/Users/marcus-sa/Git/deepkit/deepkit-framework/packages/type/src/typeguard.ts:47:15)

NB: I just realized that the assertion is bound to fail because it expects an array when the actual value is an object, but that doesn't change the fact that the error above shouldn't occur ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant