Skip to content

Commit ae53283

Browse files
committed
Handle missing LARAVEL_START during test cases
1 parent f4513c5 commit ae53283

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/AsyncTask.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function run(): void
8383
{
8484
// todo startup configs
8585
// write down the LARAVEL_START constant value for future usage
86-
$this->laravelStartVal = constant("LARAVEL_START");
86+
$this->laravelStartVal = constant("LARAVEL_START") ?? null;
8787

8888
// install a timeout detector
8989
// this single function checks all kinds of timeouts
@@ -257,10 +257,13 @@ protected function checkTaskTimeout(): void
257257

258258
// external killing; could be normal Unix timeout SIG_TERM or manual Windows taskkill
259259
// Laravel Artisan very conveniently has a LARAVEL_START = microtime(true) to let us check time elapsed
260-
$timeElapsed = microtime(true) - $this->laravelStartVal;
261-
if ($timeElapsed > $this->timeLimit) {
262-
// timeout!
263-
$hasTimedOut = true;
260+
if ($this->laravelStartVal !== null) {
261+
// we know when we have started; this can be null when running some test cases
262+
$timeElapsed = microtime(true) - $this->laravelStartVal;
263+
if ($timeElapsed > $this->timeLimit) {
264+
// timeout!
265+
$hasTimedOut = true;
266+
}
264267
}
265268

266269
// runtime timeout triggers a PHP fatal error

0 commit comments

Comments
 (0)