fix: handle missing tables in generateStaticParams during build#63
Merged
Conversation
Wrap generateStaticParams queries in try/catch so the Next.js build succeeds before Payload has created the pages/posts tables. Pages are still served at runtime via dynamicParams = true.
Code Review -- PR #63: fix: handle missing tables in generateStaticParams during build. Overall: The fix is minimal and targeted, and dynamicParams=true was already in place so the runtime fallback path is solid. Main concern: The empty catch block silences every error, not just the missing-table case. Network failures, misconfigured Payload, or query bugs would all silently return [] making them impossible to debug. Suggested fix: check err.message for the Postgres 42P01 signature ('does not exist') and re-throw anything else -- suppress only the known migration-time error. Also note per CLAUDE.md that console.log() is forbidden in production, so use a proper logger. Secondary notes: (1) Code duplication across both page files is acceptable per CLAUDE.md guidance against premature abstractions. (2) dynamicParams=true was already correct. (3) Test coverage: a unit test mocking payload.find to throw would give regression coverage. Summary: The fix solves the immediate build problem. The one actionable suggestion is narrowing the catch so unexpected errors are not silently swallowed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generateStaticParamsin[slug]/page.tsxandnews/[slug]/page.tsxwith try/catchdynamicParams = trueensures all pages still render on-demand at runtimeFixes the build error:
relation "pages" does not existduringnext build.Test plan