Skip to content

[12.x] Fix flaky test in CacheArrayStore (increment)#57905

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
sumaiazaman:fix-flaky-cache-array-store-test
Nov 25, 2025
Merged

[12.x] Fix flaky test in CacheArrayStore (increment)#57905
taylorotwell merged 1 commit into
laravel:12.xfrom
sumaiazaman:fix-flaky-cache-array-store-test

Conversation

@sumaiazaman

@sumaiazaman sumaiazaman commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

This PR fixes a flaky test by freezing time before the increment operation in testNonExistingKeysCanBeIncremented.

Problem:
Without freezing time, there's a small window where time can advance between when the cache value is incremented (which records a timestamp) and when subsequent time-based checks occur. This can cause the test to fail intermittently.

Solution:
Add Carbon::setTestNow(Carbon::now()); before the increment() operation to ensure consistent timing throughout the test.

This prevents timing race conditions where time can advance between
when the cache value is incremented (which records a timestamp) and
when subsequent time-based checks occur, causing intermittent test failures.
@taylorotwell taylorotwell merged commit 8a41491 into laravel:12.x Nov 25, 2025
76 checks passed
akyrey pushed a commit to akyrey/framework that referenced this pull request Dec 29, 2025
…7905)

This prevents timing race conditions where time can advance between
when the cache value is incremented (which records a timestamp) and
when subsequent time-based checks occur, causing intermittent test failures.
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.

2 participants