Repository navigation
fix: Compile file changes that arrived with a failed code generation - #5858
Merged
marcelomendoncasoares merged 2 commits intoOct 22, 2026
Merged
marcelomendoncasoares merged 2 commits into
marcelomendoncasoares merged 2 commits into
Conversation
Under `serverpod start`, a failed code generation returned before the batch's changed files reached the incremental compiler, and nothing recorded them. The Frontend Server kept their previous content until each file was saved again. Carry them over through the pending paths a rejected compile already uses.
Contributor
Author
|
The two failing jobs look unrelated to this change. |
1 task done
…fter-failed-generation
Contributor
Author
|
@Crazelu @marcelomendoncasoares since you both worked on #5825: I merged current main into this branch; the change applies as it was and the tests pass. While re-checking the merge case from #5857 I found a separate generator problem that shows up there since #5825, filed as #5882, and updated the description to match. |
marcelomendoncasoares
approved these changes
Oct 22, 2026
marcelomendoncasoares
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for this fix, @BiAksoy! LGTM! 🚀
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Under
serverpod start,WatchSession._handleFileChangereturns as soon as code generation fails. The changed files of that batch are handed to the incremental compiler further down, so they never reach it, and nothing records them. The next cycle invalidates only its own files, and the Frontend Server keeps the previous content of the earlier ones until each is saved again. Depending on the files, the server reloads and keeps running old code, or fails to compile a tree thatdart analyzeaccepts.The session already carries paths over when a compile is rejected, through
_pendingPathsand_pendingPackageConfig. This PR uses the same mechanism for a failed generation: the batch's source files, the generated files the watcher reported, and the files the failed generation wrote are added to_pendingPaths, so the next compile invalidates them. Apackage_config.jsonchange in that batch is carried the same way, and the native-assets builder is reset as the skipped compile would have done, so the build hooks see the new package layout.With the steps from #5857, calling
greeting.helloafter the syntax error is fixed:Before:
After:
On 99c3387, where this branch started, the merge case from the issue also compiles again once the conflict is resolved. On current
mainthat case still fails at that point, for a separate reason tracked in #5882: since #5825 the cycle after the conflict runs generation, and that generation deletes the model files the failed cycle wrote. The steps above are not affected.Tests cover a failed generation followed by a successful cycle (the earlier source, watched generated and written generated files are compiled with it), a
package_config.jsonchange in a failed cycle (invalidated on the next compile), and the same with a native-assets builder (package discovery is reset before the next hook run). The three tests fail onmain.Not changed here: a failed generation still writes the generated files without the endpoint whose file had the error. Whether the next cycle generates again was changed by #5825, which has since been merged; with it the generated files recover once the error is fixed. This branch is up to date with
main(60a7176 merged in), and the tests pass.Fixes #5857.
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.Breaking changes
None.