Repository navigation
[13.x] Respect faked Sleep in limiter block() timeout - #62017
Merged
taylorotwell merged 1 commit intoOct 14, 2026
Merged
Conversation
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.
ConcurrencyLimiter::block()(Redis and Cache) andDurationLimiter::block()already wait viaSleep::usleep()(since #46904), but the timeout is measured with nativetime(). Faked sleeps never advance that clock,so in tests:
Sleep::fake(), the loop busy-spins against the store (hundreds of thousands of iterations) until the timeout elapses in real time;Sleep::fake(syncWithCarbon: true), Carbon advances whiletime()doesn't — on thearraystore the held lock expires by Carbon time before the limiter times out, soCache::funnel()->block()runs thecallback instead of throwing
LimiterTimeoutException.This switches the timeout check in
block()toCarbon::now()->getTimestamp(), matchingCache\Lock::block(), which already measures its timeout viaCarbon::now(). WithSleep::fake(syncWithCarbon: true)ablocked limiter now times out immediately:
Runtime behaviour is unchanged — outside of tests
Carbon::now()equalstime(). The timestamps passed to theDurationLimiterLua scripts are intentionally left untouched to keep this change scoped toblock().Note: as with
Cache\Lock::block(), combining a blocked limiter withSleep::fake()(withoutsyncWithCarbon) and a frozen clock will wait indefinitely, since nothing advances the frozen time. UseSleep::fake(syncWithCarbon: true)in that case.Added a regression test in
tests/Cache/ConcurrencyLimiterTest.php.