Skip to content

Commit 1839e7e

Browse files
Block background TaskWatchdog from racing testActivityRetriesBeforeResumingWorkflow
Same CI-flake pattern 50028c9 fixed for two other tests: the testbench queue workers' wake() poll calls TaskWatchdog::runPass in a separate PHP process with a real-time now(). This test sets Carbon to 2026-04-09, so every Ready task it drives through the DB carries a created_at ten real-time-days in the past. TaskRepairPolicy::dispatchOverdue reads any task whose created_at is more than redispatchAfterSeconds (3s) behind now() as overdue, so the background worker redispatches the task via the real Bus (Queue::fake only intercepts the test process's queue), and a worker then claims it before the test's next runReadyTaskForRun() lookup lands — "Expected a ready workflow task for run ..." at V2WorkflowTest:8194. Pre-setting LOOP_THROTTLE_KEY for 60s makes any background wake() in that window short-circuit at the throttle check, matching the pattern already used for testActivityHeartbeatRenewsCurrentAttemptLease and testRepairRecreatesMissingParentResumeTaskFromChildResolutionHistory. Verified 15/15 green locally against the same docker stack that previously reproduced ~10% flake (1/10 failing runs before the fix). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 09f7e56 commit 1839e7e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/Feature/V2/V2WorkflowTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,14 @@ public function testReplayBlocksTerminalChildProjectionWithoutTypedParentStepHis
10791079

10801080
public function testActivityRetriesBeforeResumingWorkflow(): void
10811081
{
1082+
// Block the background TaskWatchdog so the testbench queue workers'
1083+
// wake() poll doesn't race our Queue::fake-driven Ready tasks. Each
1084+
// runReadyTaskForRun() creates a new Ready task whose created_at is
1085+
// stamped with the test's Carbon clock (2026-04-09), which reads as
1086+
// "overdue by days" from the worker's real-time now() and triggers a
1087+
// redispatch that can race with the test's direct handle() invocation.
1088+
Cache::put(TaskWatchdog::LOOP_THROTTLE_KEY, true, 60);
1089+
10821090
Queue::fake();
10831091
Carbon::setTestNow(Carbon::parse('2026-04-09 12:00:00'));
10841092

0 commit comments

Comments
 (0)