11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.13k stars 495 forks source link

Bug Report: Circular Structure Error in Hot Reload with .11ty.js Files #3481

Open teamchan3 opened 2 weeks ago

teamchan3 commented 2 weeks ago

Operating system

maxOS 15.0.1

Eleventy

version: 3.0.0

Describe the bug

I encountered a build error related to circular structure when using .11ty.js files. The error occurs specifically during hot reloading after editing the file.

Steps to Reproduce:

  1. Create a new index.11ty.js file with the following content: export default "<p>aaa</p>";

  2. Run Eleventy in serve mode: npx @11ty/eleventy --serve

  3. Edit and save index.11ty.js in an editor.

  4. The following error is thrown in the console, and the hot reload fails: reload-client.js:21 [11ty][02:36:03.136 UTC] Build error: Converting circular structure to JSON

Expected Behavior:

The hot reload should work without throwing an error when editing .11ty.js files.

Actual Behavior:

When editing and saving the file, a “Converting circular structure to JSON” error is thrown, and hot reload does not work.

Error Log:

reload-client.js:21 [11ty][02:36:03.136 UTC] Build error: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'page' -> object with constructor 'Object'
    --- property 'rawInput' closes the circle
{stack: 'TypeError: Converting circular structure to JSON\n …de_modules/@11ty/eleventy/src/Eleventy.js:1207:4)', message: "Converting circular structure to JSON\n    --> star…ct'\n    --- property 'rawInput' closes the circle"}

• Eleventy version: 3.0.0 • Node.js version: 22.1.0 • OS: maxOS 15.0.1

This issue only seems to occur with .11ty.js files; it does not happen with .njk files. It appears related to the hot reload process involving reload-client.js.

I would appreciate any guidance on how to resolve this or whether a fix is required.

This format should provide enough clarity and detail for the Eleventy team to investigate the issue.

Reproduction steps

No response

Expected behavior

No response

Reproduction URL

No response

Screenshots

No response

zachleat commented 5 days ago

Can anyone else reproduce this one? I tried with the instructions provided and was unable to reproduce.