Skip to content

Commit 8887e29

Browse files
Restore workflow overlap guard for exception jobs
1 parent da8240c commit 8887e29

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/Exception.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Support\Facades\Cache;
1414
use Throwable;
1515
use Workflow\Exceptions\TransitionNotFound;
16+
use Workflow\Middleware\WithoutOverlappingMiddleware;
1617
use Workflow\Models\StoredWorkflow;
1718
use Workflow\Models\StoredWorkflowLog;
1819
use Workflow\Serializers\Serializer;
@@ -81,7 +82,14 @@ public function handle()
8182

8283
public function middleware()
8384
{
84-
return [];
85+
return [
86+
new WithoutOverlappingMiddleware(
87+
$this->storedWorkflow->id,
88+
WithoutOverlappingMiddleware::WORKFLOW,
89+
0,
90+
15
91+
),
92+
];
8593
}
8694

8795
private function shouldPersistAfterProbeReplay(): bool

tests/Unit/ExceptionTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Tests\Fixtures\TestWorkflow;
2222
use Tests\TestCase;
2323
use Workflow\Exception;
24+
use Workflow\Middleware\WithoutOverlappingMiddleware;
2425
use Workflow\Models\StoredWorkflow;
2526
use Workflow\Serializers\Serializer;
2627
use Workflow\States\WorkflowRunningStatus;
@@ -34,7 +35,13 @@ public function testMiddleware(): void
3435
'Test exception'
3536
));
3637

37-
$this->assertSame([], $exception->middleware());
38+
$middleware = collect($exception->middleware())
39+
->values();
40+
41+
$this->assertCount(1, $middleware);
42+
$this->assertSame(WithoutOverlappingMiddleware::class, $middleware[0]::class);
43+
$this->assertSame(WithoutOverlappingMiddleware::WORKFLOW, $middleware[0]->type);
44+
$this->assertSame(15, $middleware[0]->expiresAfter);
3845
}
3946

4047
public function testExceptionWorkflowRunning(): void

0 commit comments

Comments
 (0)