Skip to content

Commit f2b9d85

Browse files
[1.x] Prevent memory leak on pulse:check command when using Telescope (#426)
* Prevent memory leak * Fix * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 1ff6403 commit f2b9d85

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

phpstan.neon.dist

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ parameters:
22
paths:
33
- src
44
level: 8
5+
ignoreErrors:
6+
- "#Class Laravel\\\\Telescope\\\\Contracts\\\\EntriesRepository not found#"
7+
- "#Call to static method store\\(\\) on an unknown class Laravel\\\\Telescope\\\\Telescope#"

src/Commands/CheckCommand.php

+12
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,23 @@ public function handle(
6868

6969
$pulse->ingest();
7070

71+
$this->ensureTelescopeEntriesAreCollected();
72+
7173
if ($isVapor || $this->option('once')) {
7274
return self::SUCCESS;
7375
}
7476

7577
Sleep::until($now->addSecond());
7678
}
7779
}
80+
81+
/**
82+
* Schedule Telescope to store entries if enabled.
83+
*/
84+
protected function ensureTelescopeEntriesAreCollected(): void
85+
{
86+
if ($this->laravel->bound(\Laravel\Telescope\Contracts\EntriesRepository::class)) {
87+
\Laravel\Telescope\Telescope::store($this->laravel->make(\Laravel\Telescope\Contracts\EntriesRepository::class));
88+
}
89+
}
7890
}

0 commit comments

Comments
 (0)