Skip to content

Commit

Permalink
Catch a potential JSON decoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Apr 24, 2024
1 parent a4f5c6e commit c2881ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Supervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ private function doSupervise(): void
$this->executeLocked(
function (): void {
if ($this->filesystem->exists($this->getStorageFile())) {
$this->storage = json_decode(file_get_contents($this->getStorageFile()), true, 512, JSON_THROW_ON_ERROR);
try {
$this->storage = json_decode(file_get_contents($this->getStorageFile()), true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException) {
$this->storage = [];
}
}

// Update the storage with still running processes
Expand Down

0 comments on commit c2881ce

Please sign in to comment.