Skip to content

Repro: snippet self-import causes infinite recursion#155

Open
Blargian wants to merge 1 commit into
mintlify:mainfrom
Blargian:snippet-self-import-recursion-repro
Open

Repro: snippet self-import causes infinite recursion#155
Blargian wants to merge 1 commit into
mintlify:mainfrom
Blargian:snippet-self-import-recursion-repro

Conversation

@Blargian
Copy link
Copy Markdown

@Blargian Blargian commented May 9, 2026

Summary

This is not intended to be merged — it is a minimal reproducer for a Mintlify CLI bug, opened against mintlify/starter per request so the diff is easy to review.

A snippet that imports itself (or two snippets that import each other) sends Mintlify's snippet loader into infinite recursion. The CLI hangs at preparing local preview… and the underlying Node process pins a CPU core at 100%.

Repro

Added on top of mintlify/starter:

  • snippets/self.mdx — imports itself and renders <Self /> inside its own body.
  • snippet-recursion-repro.mdx — page that imports snippets/self.mdx.
  • docs.json — page added to the "Getting started" group.
  • REPRO.md — full write-up.
git clone -b snippet-self-import-recursion-repro https://github.com/Blargian/Test
cd Test
mint dev
# open http://localhost:3939/snippet-recursion-repro

Observed

  • mint dev never reaches ✓ preview ready; @mintlify/cli Node process sits at 100% CPU indefinitely.
  • mint broken-links never completes.
  • Production builds on Mintlify hosted time out with "Update failed - Update failed after exhausting all retries"

Expected

The loader should detect a snippet importing itself (or any cycle in the snippet import graph) and either surface a clear error, or stop recursion at the first level.

Notes

  • Mutual cycles (A imports B, B imports A) exhibit the same behavior.
  • A linear chain (page → A → B with no cycle) renders correctly — the bug is specifically cycle detection in the snippet loader.

🤖 Generated with Claude Code


Note

Low Risk
Low risk: documentation/content-only changes that add a minimal repro for a CLI bug, with no production logic changes in this repo.

Overview
Adds a minimal reproduction case for an infinite-recursion bug when MDX snippets import themselves (or form cycles).

Introduces snippets/self.mdx (self-importing snippet) and a new page snippet-recursion-repro.mdx that renders it, wires the page into the docs.json navigation, and includes REPRO.md with steps and expected vs actual behavior.

Reviewed by Cursor Bugbot for commit 76883b4. Bugbot is set up for automated code reviews on this repo. Configure here.

Self-importing snippet (snippets/self.mdx) and a page that renders it.
mint dev hangs at 'preparing local preview...' with 100% CPU.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 76883b4. Configure here.

Comment thread snippets/self.mdx
This snippet imports itself on the line above and renders `<Self />` below.
A correct loader should detect the self-reference and stop; Mintlify recurses.

<Self /> No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-importing snippet causes infinite recursion if merged

High Severity

This PR adds a snippet (snippets/self.mdx) that imports itself and renders <Self />, registered in docs.json navigation. If merged, it triggers infinite recursion in Mintlify's snippet loader — mint dev hangs, production builds fail, and the Node process pins a CPU core at 100%. The PR description states it is "not intended to be merged," making this reproducer-only code that would be destructive in production.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 76883b4. Configure here.

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

Successfully merging this pull request may close these issues.

1 participant