react icon indicating copy to clipboard operation
react copied to clipboard

fix(react-dom): use server.node.js for Deno to prevent build hangs (#35231)

Open Garvitpant777 opened this issue 1 month ago • 4 comments

When using react-dom/server in Deno (e.g. during SSR/pre-rendering with Vite, esbuild, Rollup, TanStack Start, etc.), the current conditional export maps the deno condition to server.browser.js.

That file creates a MessageChannel for task scheduling. In Deno, an open MessageChannel port prevents the process from exiting, causing bundlers to hang forever.

Fix

Change the Deno condition to use the Node.js server bundle instead:

-  "deno": "./server.browser.js",
+  "deno": "./server.node.js",

server.node.js uses setImmediate (fully supported and non-blocking in Deno) instead of MessageChannel, so the process exits cleanly.

Impact

Instantly fixes indefinite hangs for all Deno users performing SSR/pre-rendering builds
No behavioral change for Node, Bun, Edge, Workerd, or browser environments
No new bundle required – Deno already has excellent Node.js compatibility

Reproduction & Verification
Repository: https://github.com/Yovach/deno-tanstack-start-bug-reproduction
Before (official react-dom 19.2.0)
→ deno task build or npm run build hangs forever
After applying this one-line change
→ build completes successfully in ~2–3 seconds:

✔ 62 modules transformed.
...
✔ built in 2.90s

Closes #35231



<img width="546" height="273" alt="React_PR" src="https://github.com/user-attachments/assets/bb029b34-c2b6-4c31-9608-1d1127777caa" />

@acdlite @sebmarkbage @lunaruan @bvaughn @trueadm @eps1lon @fraidev @Yovach   Please check this out...


<img width="546" height="273" alt="React_PR" src="https://github.com/user-attachments/assets/2095bfba-5e71-4745-8a2d-45673d07ab45" />

Garvitpant777 avatar Nov 28 '25 20:11 Garvitpant777

Hi @Garvitpant777!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

meta-cla[bot] avatar Nov 28 '25 20:11 meta-cla[bot]

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

meta-cla[bot] avatar Nov 28 '25 21:11 meta-cla[bot]

When using react-dom/server in Deno (e.g. during SSR/pre-rendering with Vite, esbuild, Rollup, TanStack Start, etc.), the current conditional export maps the deno condition to server.browser.js.

That file creates a MessageChannel for task scheduling. In Deno, an open MessageChannel port prevents the process from exiting, causing bundlers to hang forever.

Fix

Change the Deno condition to use the Node.js server bundle instead:

  • "deno": "./server.browser.js",
  • "deno": "./server.node.js",

server.node.js uses setImmediate (fully supported and non-blocking in Deno) instead of MessageChannel, so the process exits cleanly.

Impact

Instantly fixes indefinite hangs for all Deno users performing SSR/pre-rendering builds No behavioral change for Node, Bun, Edge, Workerd, or browser environments No new bundle required – Deno already has excellent Node.js compatibility

Reproduction & Verification Repository: https://github.com/Yovach/deno-tanstack-start-bug-reproduction Before (official react-dom 19.2.0) → deno task build or npm run build hangs forever After applying this one-line change → build completes successfully in ~2–3 seconds:

✔ 62 modules transformed. ... ✔ built in 2.90s

Closes #35231

React_PR

@acdlite @sebmarkbage @lunaruan @bvaughn @trueadm @eps1lon @fraidev @Yovach Please check this out...

React_PR

Garvitpant777 avatar Nov 29 '25 19:11 Garvitpant777

When using react-dom/server in Deno (e.g. during SSR/pre-rendering with Vite, esbuild, Rollup, TanStack Start, etc.), the current conditional export maps the deno condition to server.browser.js.

That file creates a MessageChannel for task scheduling. In Deno, an open MessageChannel port prevents the process from exiting, causing bundlers to hang forever.

Fix

Change the Deno condition to use the Node.js server bundle instead:

* "deno": "./server.browser.js",


* "deno": "./server.node.js",

server.node.js uses setImmediate (fully supported and non-blocking in Deno) instead of MessageChannel, so the process exits cleanly.

Impact

Instantly fixes indefinite hangs for all Deno users performing SSR/pre-rendering builds No behavioral change for Node, Bun, Edge, Workerd, or browser environments No new bundle required – Deno already has excellent Node.js compatibility

Reproduction & Verification Repository: https://github.com/Yovach/deno-tanstack-start-bug-reproduction Before (official react-dom 19.2.0) → deno task build or npm run build hangs forever After applying this one-line change → build completes successfully in ~2–3 seconds:

✔ 62 modules transformed. ... ✔ built in 2.90s

Closes #35231 React_PR

@acdlite @sebmarkbage @lunaruan @bvaughn @trueadm @eps1lon @fraidev @Yovach Please check this out... React_PR

Hi, a user already provided a PR here : https://github.com/facebook/react/pull/35235

Yovach avatar Dec 01 '25 08:12 Yovach

When using react-dom/server in Deno (e.g. during SSR/pre-rendering with Vite, esbuild, Rollup, TanStack Start, etc.), the current conditional export maps the deno condition to server.browser.js. That file creates a MessageChannel for task scheduling. In Deno, an open MessageChannel port prevents the process from exiting, causing bundlers to hang forever.

Fix

Change the Deno condition to use the Node.js server bundle instead:

* "deno": "./server.browser.js",


* "deno": "./server.node.js",

server.node.js uses setImmediate (fully supported and non-blocking in Deno) instead of MessageChannel, so the process exits cleanly. Impact Instantly fixes indefinite hangs for all Deno users performing SSR/pre-rendering builds No behavioral change for Node, Bun, Edge, Workerd, or browser environments No new bundle required – Deno already has excellent Node.js compatibility Reproduction & Verification Repository: https://github.com/Yovach/deno-tanstack-start-bug-reproduction Before (official react-dom 19.2.0) → deno task build or npm run build hangs forever After applying this one-line change → build completes successfully in ~2–3 seconds: ✔ 62 modules transformed. ... ✔ built in 2.90s Closes #35231 React_PR @acdlite @sebmarkbage @lunaruan @bvaughn @trueadm @eps1lon @fraidev @Yovach Please check this out... React_PR

Hi, a user already provided a PR here : #35235

With due respect would you please merge my solution if it seems a good fit to you ... Thank You

Garvitpant777 avatar Dec 03 '25 22:12 Garvitpant777