Skip to content

Client rendering crashes when configuring optimization.runtimeChunk to multiple #1558

Description

@rubenochiavone

Configuring webpack to embed the runtime in each chunk and calling react_component multiple times in a rails view/partial causes the client render to crash with the following error:

Could not find component registered with name XXX. Registered component names include [ YYY ]. Maybe you forgot to register the component?
VM4859 clientStartup.js:132 Uncaught Error: ReactOnRails encountered an error while rendering component: XXX. See above error message.
    at Object.get (ComponentRegistry.js:40:15)
    at Object.getComponent (ReactOnRails.js:211:44)
    at render (VM4859 clientStartup.js:103:53)
    at forEachReactOnRailsComponentRender (VM4859 clientStartup.js:138:9)
    at reactOnRailsPageLoaded (VM4859 clientStartup.js:164:5)
    at renderInit (VM4859 clientStartup.js:205:9)
    at onPageReady (VM4859 clientStartup.js:234:9)
    at HTMLDocument.onReadyStateChange (VM4859 clientStartup.js:238:13)

Webpack configuration

optimization: {
  runtimeChunk: 'multiple'
},

Rails view

= react_component("XXX", props: @props)
= yield
= react_component("YYY", props: @props)

Environment

  1. Ruby version: 3.1
  2. Rails version: 7.0.6
  3. Shakapacker version: 6.6.0
  4. React on Rails version: 13.3.5

Expected behavior

Should render both components.

Actual behavior

Crashes on the client with the aforementioned error/stacktrace.

Small, reproducible repo

Checkout the branch rubenochiavone/repro-issue-1558 and open the dummy/app in the following URL: http://localhost:3000/render_with_layouts_wrapper. You should see the following errors in the dev-tools console:

createReactOutput.js:53 Could not find component registered with name ReduxApp. Registered component names include [ HeaderWrapper, HelloWorld, FooterWrapper ]. Maybe you forgot to register the component?
render @ createReactOutput.js:53
forEachReactOnRailsComponentRender @ createReactOutput.js:61
reactOnRailsPageLoaded @ handleError.js:15
renderInit @ handleError.js:49
onPageReady @ isRenderFunction.js:25
onReadyStateChange @ isRenderFunction.js:25
ReactOnRails.js:18 Uncaught Error: ReactOnRails encountered an error while rendering component: ReduxApp. See above error message.
    at Object.get (ReactOnRails.js:18:1)
    at Object.getComponent (RenderUtils.js:10:1)
    at render (createReactOutput.js:26:1)
    at forEachReactOnRailsComponentRender (createReactOutput.js:61:1)
    at reactOnRailsPageLoaded (handleError.js:15:1)
    at renderInit (handleError.js:49:1)
    at onPageReady (isRenderFunction.js:25:1)
    at HTMLDocument.onReadyStateChange (isRenderFunction.js:25:1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions