Skip to content

Commit fd2b081

Browse files
committed
Fallback to time() if hrtime() is not supported
1 parent aadf370 commit fd2b081

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Scout/ScoutEngine.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use function sleep;
4545
use function sprintf;
4646
use function substr;
47+
use function time;
4748

4849
/**
4950
* In the context of this Laravel Scout engine, a "search index" refers to
@@ -526,8 +527,9 @@ private function usesSoftDelete(Model|EloquentCollection $model): bool
526527
*/
527528
private function wait(Closure $callback): void
528529
{
529-
$timeout = hrtime()[0] + self::WAIT_TIMEOUT_SEC;
530-
while (hrtime()[0] < $timeout) {
530+
// Fallback to time() if hrtime() is not supported
531+
$timeout = (hrtime()[0] ?? time()) + self::WAIT_TIMEOUT_SEC;
532+
while ((hrtime()[0] ?? time()) < $timeout) {
531533
if ($callback()) {
532534
return;
533535
}

0 commit comments

Comments
 (0)