Conversation
Deploying rspress-v2 with
|
| Latest commit: |
11825ed
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c972eb90.rspress-v2.pages.dev |
| Branch Preview URL: | https://syt-fix-ssg-md-render-cycle.rspress-v2.pages.dev |
Contributor
Rsdoctor Bundle Diff AnalysisFound 3 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
f595f54 to
5fcac8f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make renderToMarkdownString behave like React SSR (renderToString / Fizz) by ensuring React effects never execute during markdown rendering, preventing Node-side crashes such as document is not defined.
Changes:
- Intercepts React’s hooks dispatcher (
ReactSharedInternals.H) duringrenderToMarkdownStringto no-opuseEffect,useLayoutEffect, anduseInsertionEffect. - Wraps the render+commit path in a
try/finallyto restore the dispatcher after rendering. - Adds a comprehensive test suite asserting that effects (and cleanups) never run while other hooks still work.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/core/src/node/ssg-md/react/render.ts |
Adds a hooks-dispatcher interceptor to suppress effects during reconciler rendering and restores it afterward. |
packages/core/src/node/ssg-md/react/render.test.tsx |
Adds tests verifying SSR-like effect suppression (including insertion effects and cleanup). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ng to match SSR behavior React's renderToString (Fizz) uses a HooksDispatcher where useEffect and useLayoutEffect are noop. Our renderToMarkdownString uses react-reconciler which registers and executes effects, causing "document is not defined" in Node.js. Fix by intercepting ReactSharedInternals.H during the render pass to make useEffect/useLayoutEffect/useInsertionEffect no-ops.
5fcac8f to
11825ed
Compare
Member
Author
Timeless0911
approved these changes
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
assign useEffect and useLayoutEffect noop value when
renderToMarkdownStringRelated Issue
Sometimes SSG-MD will throw a 'window is not defined' error, but SSG won't.
Root Cause
React's
renderToStringuses Fizz, which has its ownHooksDispatcherwhereuseEffect/useLayoutEffectarenoop. OurrenderToMarkdownStringusesreact-reconcilerwhich goes through the full fiber render→commit cycle and executes effects.