Skip to content

Fix flaky parallel tests caused by UpgradeCommandTest route cache - #393

Merged
Cannonb4ll merged 1 commit into
mainfrom
fix/upgrade-command-test-route-cache
Nov 2, 2026
Merged

Cannonb4ll merged 1 commit into
mainfrom
fix/upgrade-command-test-route-cache

Conversation

@Cannonb4ll

Copy link
Copy Markdown
Member

Problem

UpgradeCommandTest runs roadmap:upgrade, which calls route:cache. That clears and rewrites the shared bootstrap/cache/routes-v7.php. Two things went wrong:

  1. Flaky parallel runs. Other test processes would see the cache file exist, and route:cache would delete it before they required it. Random unrelated tests then failed with require(.../bootstrap/cache/routes-v7.php): Failed to open stream.
  2. Stale route cache left behind. Every test run left routes-v7.php in place. The next run became flaky, and local development kept serving cached routes.

Fix

The test sets APP_ROUTES_CACHE to a temporary file of its own (Laravel reads this env value on every getCachedRoutesPath() call). It asserts the routes were cached there and deletes the file afterwards. Other parallel processes never touch it.

view:cache needed no change: Laravel's CompilerEngine already recompiles when a compiled view disappears mid-request.

Testing

  • On main, with a route cache present at the start: 2 of 3 parallel runs failed
  • On this branch, under the same conditions: 5 of 5 parallel runs pass (1150 tests), plus a clean run
  • After a clean run, bootstrap/cache contains no routes-v7.php

roadmap:upgrade runs route:cache, which cleared and rewrote the shared
bootstrap/cache/routes-v7.php. During a parallel run other processes could
see the file exist and then fail to require it, and the cache was left
behind for later runs and local development.

The test now points APP_ROUTES_CACHE at its own temporary file, asserts the
routes were cached there, and removes it afterwards.
@Cannonb4ll
Cannonb4ll merged commit c6252f0 into main Nov 2, 2026
4 checks passed
@Cannonb4ll
Cannonb4ll deleted the fix/upgrade-command-test-route-cache branch November 2, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant