Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: [PPR] Resume failed when "moduleLoading === undefined" in function prepareDestinationWithChunks #28658

Open
gaoachao opened this issue Mar 27, 2024 · 0 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@gaoachao
Copy link

gaoachao commented Mar 27, 2024

React version:
experimental

Steps To Reproduce

const serverResponse = createFromReadableStream(renderStream, {
  ssrManifest: {
    moduleMap: ssrModuleMapping,
    // This way can also solve the error
    // moduleLoading: null,
  },
});
// Both prerender and resume faild when ssrManifest.moduleLoading === undefined
// <Root /> comes from serverResponse 
const { prelude, postponed } = await prerenderToNodeStream(
  <Root />,
  prerenderOptions
);
const { pipe } = await resumeToPipeableStream(
  <Root />,
  postponed,
  resumeOptions
);

Link to code example:

The current behavior

TypeError: Cannot read properties of undefined (reading 'prefix') at prepareDestinationWithChunks

export function prepareDestinationWithChunks(
  moduleLoading: ModuleLoading,
  // Chunks are double-indexed [..., idx, filenamex, idy, filenamey, ...]
  chunks: Array<string>,
  nonce: ?string,
) {
  if (moduleLoading !== null) {
    for (let i = 1; i < chunks.length; i += 2) {
      preinitScriptForSSR(
        moduleLoading.prefix + chunks[i],
        nonce,
        moduleLoading.crossOrigin,
      );
    }
  }
}

The expected behavior

// In fact, this is not a bug in the general sense, but it may make prepareDestinationWithChunks more rigorous.
export function prepareDestinationWithChunks(
  moduleLoading: ModuleLoading,
  // Chunks are double-indexed [..., idx, filenamex, idy, filenamey, ...]
  chunks: Array<string>,
  nonce: ?string
) {
  // or if (moduleLoading) {}
  if (moduleLoading !== null && moduleLoading !== undefined) {
    for (let i = 1; i < chunks.length; i += 2) {
      preinitScriptForSSR(
        moduleLoading.prefix + chunks[i],
        nonce,
        moduleLoading.crossOrigin
      );
    }
  }
}
@gaoachao gaoachao added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 27, 2024
@gaoachao gaoachao changed the title Bug: []moduleLoading === undefined In function prepareDestinationWithChunks Bug: [PPR] resume failed when "moduleLoading === undefined" in function prepareDestinationWithChunks Mar 27, 2024
@gaoachao gaoachao changed the title Bug: [PPR] resume failed when "moduleLoading === undefined" in function prepareDestinationWithChunks Bug: [PPR] Resume failed when "moduleLoading === undefined" in function prepareDestinationWithChunks Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

1 participant