Skip to content

Commit 0ae8b92

Browse files
committed
Adjust task timeout checks
1 parent 161388f commit 0ae8b92

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/AsyncTask.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ class AsyncTask
4747
*/
4848
private const LARAVEL_START = "LARAVEL_START";
4949

50+
/**
51+
* The time epsilon that will be added to timeout checks to ensure we can correctly handle Unix timeouts.
52+
*
53+
* This is a workaround to the undetectable but inevitable Unix PHP startup delay.
54+
* @var float
55+
*/
56+
private const TIME_EPSILON = 0.1;
57+
5058
/**
5159
* Indicates whether GNU coreutils is found in the system; in particular, we are looking for the timeout command inside coreutils.
5260
*
@@ -266,7 +274,7 @@ protected function checkTaskTimeout(): void
266274
if ($this->laravelStartVal !== null) {
267275
// we know when we have started; this can be null when running some test cases
268276
$timeElapsed = microtime(true) - $this->laravelStartVal;
269-
if ($timeElapsed >= $this->timeLimit) {
277+
if ($timeElapsed + self::TIME_EPSILON >= $this->timeLimit) {
270278
// timeout!
271279
$hasTimedOut = true;
272280
}

0 commit comments

Comments
 (0)