Fix out-of-memory error during wayfinder:generate on a cold cache - #287
Merged
joetannenbaum merged 6 commits intoSep 9, 2026
Merged
Conversation
The static analysis pass keeps every analyzed scope in memory and can exceed PHP's default 128M limit on a cold cache, causing a fatal out-of-memory error mid-generation. Since this is a build-time command, lift the memory limit when it has been capped instead of failing mid-generation.
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
alaminfirdows
marked this pull request as ready for review
July 6, 2026 05:22
Collaborator
|
Thank you! |
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.
Description
wayfinder:generatefatal-errors withAllowed memory size of 134217728 bytes exhaustedwhen run against a cold cache (emptystorage/wayfinder-cache) under PHP's default 128M memory limit (see #167).The static analysis pass (via
laravel/surveyor) retains every analyzed scope in memory for the duration of the walk, and that working set exceeds 128M for non-trivial applications on a first run. The command then dies mid-generation instead of producing output.This change lifts the memory limit for the
wayfinder:generatecommand when it has been capped. It is a build-time, short-lived CLI process (the same approach used by Composer and other code-generation tools), so removing the cap is safe and lets generation complete reliably regardless of application size.Closes #167
Benefit to end users
Users can run
php artisan wayfinder:generate(directly, or via the Vite plugin duringnpm run build) under the default PHP memory configuration without hitting a fatal out-of-memory error on a cold cache.Non-breaking changes
memory_limit = -1, the command is a no-op.ini_setis suppressed, so environments that forbid changing the limit at runtime fall back to the previous behavior rather than erroring.Tests
Added
test_generate_completes_under_default_memory_limit, which runswayfinder:generatein a subprocess constrained tomemory_limit=128Mand asserts it succeeds. This fails before the change (fatal OOM) and passes after. The existingGenerateCommandTestsuite and the VitestglobalSetupbuild (which runswayfinder:generateat the default limit) also complete under 128M with this change.