[CLI] Exit non-zero with a clear message when next typegen fails#94241
Merged
Conversation
Contributor
Stats cancelledCommit: 86fe01c |
Contributor
Tests PassedCommit: 86fe01c |
Comment on lines
+532
to
+536
| '\n> Failed to generate route types. The global `PageProps` and ' + | ||
| '`LayoutProps` helpers and other generated route types were not ' + | ||
| "written, which can surface as `Cannot find name 'PageProps'` " + | ||
| 'errors during type checking. This is often caused by ' + | ||
| '`next.config` failing to load. Original error:\n' |
Contributor
There was a problem hiding this comment.
this seems a little wordy, do we really need to say that the types were not written? (actually they may have been written if the failure was late enough)
A simple: Unexpected error while generating route types, Original error:\n is probably enough.
lukesandberg
approved these changes
May 29, 2026
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.
The
typegencommand chainednextTypegen(...).then(() => process.exit(0))with no rejection handler. Whennext.configthrows duringloadConfig, the rejection is orphaned by the synchronousprogram.parseand then absorbed by Next'sunhandledRejectionfilter, so the process exits0having written no route types. A latertscthen reportsCannot find name 'PageProps'/'LayoutProps'(and missing*.pngmodules) with nothing tying it back to typegen. Add a.catchthat prints an actionable message about the missing route types andprocess.exit(1), sonext typegen && tschalts on failure. Includes an e2e test whose fixture config throws and asserts a non-zero exit with the diagnostic.