Skip to content

Static generation fails for nextjs: chunks not loaded, Flight payload returns embedded 404 in raw <pre> text #874

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

Open
Dragosp33 opened this issue May 23, 2025 · 3 comments

Comments

@Dragosp33
Copy link

Summary

I am encountering a rare client-side rendering issue in my Next.js app deployed via SST on AWS.

Occasionally, when returning to a tab left inactive for a long time (on the /home page), the app fails to render properly.

Instead of rendering the React components, the client receives a raw <pre> block.

This causes the app to break visually and behave unexpectedly.

This is what it looks like:
react-fragment-error

The app uses the Next.js App Router with nested layouts.

The folder structure includes:

app/[domain]/... — tenant-specific subdomains

app/main — the main app; the root / page is rewritten to main/(presentation)/home/page.tsx.

Middleware rewrites requests to /main when no subdomain is present, and to /[domain] when a subdomain exists.

The error seems linked to this setup but only happens rarely.

The build and deployment are handled via SST on AWS.

I’m not sure if this is related to caching, stale Flight data, or chunk loading — but the raw <pre> containing a 404 page in the payload is what I'm thinking about.

this is the notFound message that I found in the <pre> text:

react-fragment-notFound

I currently don’t have a minimal reproduction repo because I’m unsure how to reproduce it, I'm not sure what causes it exactly.
Instead, you can check the live page here.

Additional information

Next version: 15.1.7
SST version: 3.4.27
@sommeeeer
Copy link
Contributor

Are you sure that is the correct SST version? What version of OpenNext is this btw?

@conico974
Copy link
Contributor

This is RSC, the issue is very likely caching and also likely not related to OpenNext itself.
What's in your sst.config.ts, in the Nextjs construct ?

@Dragosp33
Copy link
Author

Are you sure that is the correct SST version? What version of OpenNext is this btw?

So, this is the version that npx sst version shows: 3.4.27. However, just sst version in wsl shows 3.2.76

This is RSC, the issue is very likely caching and also likely not related to OpenNext itself. What's in your sst.config.ts, in the Nextjs construct ?

This is the sst.config:

export default $config({
  app(input) {
    return {
      name: 'auth-lucia-test',
      removal: input?.stage === 'production' ? 'retain' : 'remove',
      protect: ['production'].includes(input?.stage),
      home: 'aws',
    };
  },
  async run() {
    console.log('APP RUN');
    new sst.aws.Nextjs('MyWeb', {
      domain: {
        name: 'weshift.shop',
        aliases: ['*.weshift.shop'],
        redirects: ['www.weshift.shop'],
      },
      warm: 5,
      },
    });
  },
});

And this is the open-next.config:

const config = {
  default: {
    override: {
      wrapper: 'aws-lambda-streaming',
    },
  },
};

export default config;

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

No branches or pull requests

3 participants