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

Stitches throwing exceptions "TypeError - Converting circular structure to JSON" #832

Closed
YuvalZiegler opened this issue Oct 6, 2021 · 2 comments · May be fixed by #1004
Closed

Stitches throwing exceptions "TypeError - Converting circular structure to JSON" #832

YuvalZiegler opened this issue Oct 6, 2021 · 2 comments · May be fixed by #1004

Comments

@YuvalZiegler
Copy link

YuvalZiegler commented Oct 6, 2021

Bug report

We use stitches at attentive to power our internal component library and style system, we love it, so first off, thank you! Part of what we do at attentive is render UI on our clients' sites, we recently switched to using our new internal library, powered by stitches, and ran into this circular dependency issue.

Describe the bug

When any circular dependency exists in the document, createStitches fails

To Reproduce

I've created a code sandbox that reproduces the issue here: https://codesandbox.io/s/circular-json-reproduction-0i5lp?file=/src/App.tsx

to reproduce locally:

document.someLib = {};
document.someLib.ref = someLib;

const { styled } = createStitches({});
// ^ throws  "TypeError - Converting circular structure to JSON"

Expected behavior

Should be able to handle circular JSON

Screenshots

with a circular dep:

Screen Shot 2021-10-06 at 10 36 24 AM

without

Screen Shot 2021-10-06 at 10 37 35 AM

System information

  • OS: macOS (but will affect all)
  • Browser: All
  • Version of Stitches: 1.2.3

Note

Related to this issue was recently closed: #665 (comment)

@peduarte
Copy link
Contributor

peduarte commented Oct 6, 2021

Hey, I created a PR (#836)

I've forked your sandbox, and updated the dependency to use the build from that PR.

Here's a sandbox: https://codesandbox.io/s/circular-json-reproduction-forked-w3cr5?file=/package.json

Looks like that fixes the problem

@YuvalZiegler
Copy link
Author

this is great! thanks for the fast fix!

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

Successfully merging a pull request may close this issue.

2 participants