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

Closed
gaoachao opened this issue Mar 27, 2024 · 2 comments
Labels
Resolution: Stale Automatically closed due to inactivity 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 Mar 27, 2024
@gaoachao gaoachao changed the title Bug: [PPR] resume failed when "moduleLoading === undefined" in function prepareDestinationWithChunks Mar 27, 2024
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Jun 25, 2024
Copy link

github-actions bot commented Jul 2, 2024

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Stale Automatically closed due to inactivity Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
1 participant