Skip to content

Commit

Permalink
[1.x] Prevent memory leak on pulse:check command when using Telesco…
Browse files Browse the repository at this point in the history
…pe (#426)

* Prevent memory leak

* Fix

* formatting

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
gdebrauwer and taylorotwell authored Nov 29, 2024
1 parent 1ff6403 commit f2b9d85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ parameters:
paths:
- src
level: 8
ignoreErrors:
- "#Class Laravel\\\\Telescope\\\\Contracts\\\\EntriesRepository not found#"
- "#Call to static method store\\(\\) on an unknown class Laravel\\\\Telescope\\\\Telescope#"
12 changes: 12 additions & 0 deletions src/Commands/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,23 @@ public function handle(

$pulse->ingest();

$this->ensureTelescopeEntriesAreCollected();

if ($isVapor || $this->option('once')) {
return self::SUCCESS;
}

Sleep::until($now->addSecond());
}
}

/**
* Schedule Telescope to store entries if enabled.
*/
protected function ensureTelescopeEntriesAreCollected(): void
{
if ($this->laravel->bound(\Laravel\Telescope\Contracts\EntriesRepository::class)) {
\Laravel\Telescope\Telescope::store($this->laravel->make(\Laravel\Telescope\Contracts\EntriesRepository::class));
}
}
}

0 comments on commit f2b9d85

Please sign in to comment.