Skip to content

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

@YuvalZiegler

Description

@YuvalZiegler

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions