Skip to content

Commit

Permalink
Merge pull request #1354 from laravel/fix/serialization-of-trace
Browse files Browse the repository at this point in the history
[4.x] Avoids serialialisation of exception traces
  • Loading branch information
nunomaduro committed Jun 2, 2023
2 parents 08930ad + 8ef3048 commit 9e30c9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Watchers/JobWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Queue\Events\JobProcessed;
use Illuminate\Queue\Queue;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Laravel\Telescope\EntryType;
use Laravel\Telescope\EntryUpdate;
Expand Down Expand Up @@ -124,7 +125,7 @@ public function recordFailedJob(JobFailed $event)
'status' => 'failed',
'exception' => [
'message' => $event->exception->getMessage(),
'trace' => $event->exception->getTrace(),
'trace' => collect($event->exception->getTrace())->map(fn ($trace) => Arr::except($trace, ['args']))->all(),
'line' => $event->exception->getLine(),
'line_preview' => ExceptionContext::get($event->exception),
],
Expand Down
4 changes: 4 additions & 0 deletions tests/Watchers/JobWatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public function test_failed_jobs_register_entry()
$this->assertSame('default', $entry->content['queue']);
$this->assertSame('I never watched Star Wars.', $entry->content['data']['message']);
$this->assertArrayHasKey('exception', $entry->content);

$this->assertArrayNotHasKey('args', $entry->content['exception']['trace'][0]);
$this->assertSame(MyFailedDatabaseJob::class, $entry->content['exception']['trace'][0]['class']);
$this->assertSame('handle', $entry->content['exception']['trace'][0]['function']);
}

private function createJobsTable(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Watchers/NotificationWatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private function performNotificationAssertions($channel, $route)
$this->assertFalse($entry->content['queued']);
$this->assertStringContainsString(is_array($route) ? implode(',', $route) : $route, $entry->content['notifiable']);
$this->assertSame($channel, $entry->content['channel']);
$this->assertNull($entry->content['response']);
$this->assertEmpty($entry->content['response']);
}
}

Expand Down

0 comments on commit 9e30c9e

Please sign in to comment.