From c7ec908c1c4a938f43efbd041a33b1d538aecf2c Mon Sep 17 00:00:00 2001 From: Dariusz Gafka Date: Sun, 27 Sep 2026 08:00:00 +0200 Subject: [PATCH] fix: wait legacy projection gap retries in milliseconds, not microseconds (fixes #701) --- .../PdoEventSourcing/src/Prooph/GapDetection.php | 14 +++++++++++++- .../GapDetectionInSynchronousProjectionTest.php | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/PdoEventSourcing/src/Prooph/GapDetection.php b/packages/PdoEventSourcing/src/Prooph/GapDetection.php index 68662f43d..89327c28b 100644 --- a/packages/PdoEventSourcing/src/Prooph/GapDetection.php +++ b/packages/PdoEventSourcing/src/Prooph/GapDetection.php @@ -25,6 +25,18 @@ public function getDefinition(): Definition public function build(): ProophGapDetection { - return new ProophGapDetection($this->retryConfig, $this->detectionWindow?->build()); + return new ProophGapDetection($this->retryDelaysInMicroseconds(), $this->detectionWindow?->build()); + } + + private function retryDelaysInMicroseconds(): ?array + { + if ($this->retryConfig === null) { + return null; + } + + return array_map( + static fn (int $delayInMilliseconds): int => $delayInMilliseconds * 1000, + $this->retryConfig, + ); } } diff --git a/packages/PdoEventSourcing/tests/Integration/GapDetectionInSynchronousProjectionTest.php b/packages/PdoEventSourcing/tests/Integration/GapDetectionInSynchronousProjectionTest.php index 338844d21..d1db93ea5 100644 --- a/packages/PdoEventSourcing/tests/Integration/GapDetectionInSynchronousProjectionTest.php +++ b/packages/PdoEventSourcing/tests/Integration/GapDetectionInSynchronousProjectionTest.php @@ -120,6 +120,17 @@ public function test_detecting_gaps_with_detection_window(): void ); } + public function test_retry_delays_are_waited_in_milliseconds_before_skipping_gap(): void + { + $ecotone = $this->bootstrapEcotoneWithGapDetection(new GapDetection([0, 300], new DateInterval('PT60S'))); + + $startedAt = microtime(true); + $ecotone->sendCommand(new CloseTicket('124')); + $elapsedMilliseconds = (microtime(true) - $startedAt) * 1000; + + self::assertGreaterThanOrEqual(300, $elapsedMilliseconds); + } + public function test_running_projection_without_gap_detection(): void { $ecotone = $this->bootstrapEcotoneWithGapDetection(null);