payloadcms / payloadcms/payload

Ecommerce Template: 404 Causes Infinite Loop

Open
#14,626 3 comments 0 reactions 1 assignee View on GitHub

@paulpopus is already working on this.

Since Nov 14, 2025.

Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

Issue

In production, when a page slug isn't found, it results in an infinite 404 loop, with the not-found.tsx page reloading over and over.

Thoughts

This used to be a Next issue in development mode but I can't find much info about it happening in production.

One thing I noticed is that if you wrap the page content (children) within (app)/layout in a suspense boundary the layout becomes server rendered and the not-found page streams in and doesn't loop. However this introduces a completely different issue in that it makes all Link components on the page stop working, which effectively breaks the page, even though it makes sense to have a suspense boundary here.

Some issues that are related to the latter issue but may help to debug:
Vercel: 404 page isn't server rendered when using notFound()
Vercel: not-found.tsx not working

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/tree/main/templates/ecommerce

Reproduction Steps
  1. Set up the template using the CLI: pnpx create-payload-app not-found-loop -t ecommerce
  2. Start the server in production: pnpm dev:prod
  3. Visit localhost:3000/foo
Which area(s) are affected? (Select all that apply)

area: templates

Environment Info
Binaries:
  Node: 24.9.0
  npm: 11.6.0
  Yarn: 1.22.22
  pnpm: 10.17.1
Relevant Packages:
  payload: 3.64.0
  next: 15.5.6
  @payloadcms/db-mongodb: 3.64.0
  @payloadcms/email-nodemailer: 3.64.0
  @payloadcms/graphql: 3.64.0
  @payloadcms/live-preview: 3.64.0
  @payloadcms/live-preview-react: 3.64.0
  @payloadcms/next/utilities: 3.64.0
  @payloadcms/plugin-form-builder: 3.64.0
  @payloadcms/plugin-seo: 3.64.0
  @payloadcms/richtext-lexical: 3.64.0
  @payloadcms/translations: 3.64.0
  @payloadcms/ui/shared: 3.64.0
  react: 19.2.0
  react-dom: 19.2.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.