diff --git a/src/Activity.php b/src/Activity.php index 560ee83..dec936e 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -58,6 +58,8 @@ public function __construct( if (property_exists($this, 'queue')) { $this->onQueue($this->queue); } + + $this->afterCommit = true; } public function backoff() diff --git a/src/Workflow.php b/src/Workflow.php index 67a1e6f..3d7902c 100644 --- a/src/Workflow.php +++ b/src/Workflow.php @@ -65,6 +65,8 @@ public function __construct( if (property_exists($this, 'queue')) { $this->onQueue($this->queue); } + + $this->afterCommit = true; } public function query($method) diff --git a/tests/Feature/DispatchWorkflowInTransactionTest.php b/tests/Feature/DispatchWorkflowInTransactionTest.php new file mode 100644 index 0000000..5038c4c --- /dev/null +++ b/tests/Feature/DispatchWorkflowInTransactionTest.php @@ -0,0 +1,51 @@ + 1, "workflow_id" => $workflow->id()]) + */ + + /** + * dispatch the workflow to the queue + */ + $workflow->start(); + + /** + * pretend that committing the transaction takes a while + */ + sleep(3); + }); + + /** + * the workflow stays in the pending state as the transaction was not committed + * when the worker was told to process the workflow + * + * the exception is silently caught in src/Workflow.php:115 + */ + while ($workflow->running() && $workflow->exceptions()->isEmpty() && now()->diffInSeconds($start) < 15); + + $this->assertSame(WorkflowCompletedStatus::class, $workflow->status()); + $this->assertEmpty($workflow->exceptions()); + } +} diff --git a/tests/Fixtures/TestSimpleWorkflow.php b/tests/Fixtures/TestSimpleWorkflow.php new file mode 100644 index 0000000..400a509 --- /dev/null +++ b/tests/Fixtures/TestSimpleWorkflow.php @@ -0,0 +1,22 @@ +
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: