Skip to content

Remove MessageChannel shim #2247 - #2248

Open
rymsha wants to merge 1 commit into
masterfrom
claude/react4xp-timers-window-docs-d3i9qg
Open

Remove MessageChannel shim #2247#2248
rymsha wants to merge 1 commit into
masterfrom
claude/react4xp-timers-window-docs-d3i9qg

Conversation

@rymsha

@rymsha rymsha commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #2247

Since enonic/npm-react4xp#1627 (@enonic/react4xp 7.0.0), SSR bundles resolve React with the edge-light condition and load react-dom/server.edge, which does not construct a MessageChannel at module load. The transitional shim in nodePolyfills.ts is therefore no longer needed.

Beyond being unnecessary, the shim clashed with how the edge build (and React's scheduler package) is designed to behave: they feature-detect globals like MessageChannel and pick fallbacks when absent. The shim's no-op ports made that detection succeed while message delivery silently never happened — code taking the MessageChannel path would hang instead of using its own fallback or failing loudly. With the shim gone, feature detection works as intended.

Changes

  • nodePolyfills.ts — remove the MessagePortShim function and the MessageChannel install block. Timers, TextEncoder, and atob/btoa polyfills are unchanged (still required — server.edge looks up TextEncoder at module load).
  • RendererTest.java — remove the test that pinned the shim's contract (render_real_react_component_via_server_browser_with_message_channel_shim). The server.edge test with a real React 19 bundle remains and covers the production path.
  • Remove the orphaned wiring: src/test/js/react-bundle-server-browser-entry.js, the build:react-server-browser-test-bundle npm script, and the bundleReactServerBrowserForTest Gradle task.

Compatibility

Apps must build with @enonic/react4xp >= 7.0.0. Assets compiled with 6.x (bundling react-dom/server.browser) will now fail at SSR engine warmup with MessageChannel is not defined. The upgrade notes in doc-react4xp state this (enonic/doc-react4xp#1).

Verification

  • tsc --noEmit -p tsconfig.graal.json passes
  • rollup nodePolyfills build succeeds
  • ./gradlew test --tests "...RendererTest" green, including the real react-dom/server.edge render in a GraalJS context

🤖 Generated with Claude Code

https://claude.ai/code/session_01FxjAJqqTs6SpY2ze8nZJYm

Since @enonic/react4xp 7.0.0 resolves React packages with the edge-light
condition (enonic/npm-react4xp#1627), SSR bundles load react-dom/server.edge,
which does not construct a MessageChannel at module load. The shim only
existed to let server.browser bundles load, so it can go, along with the
server.browser test bundle and the test that pinned the shim's contract.

Apps must build with @enonic/react4xp >= 7.0.0; older bundles resolving
react-dom/server.browser will now fail to load at SSR engine warmup.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxjAJqqTs6SpY2ze8nZJYm
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.

Remove MessageChannel shim

4 participants