[1.x] Run catch callbacks when a broadcast agent job fails

Merged
ME
7d ago
+58-9

broadcastOnQueue() returns a BroadcastAgent job, which accepts catch() callbacks through InvokesQueuedResponseCallbacks, but they never run. The trait runs them from its failed() method, and BroadcastAgent declares its own failed() to broadcast the stream_failed event. The class method takes precedence over the trait's, so a failed broadcast job broadcasts the error and silently skips the callbacks:

(new FailingAgent)
    ->broadcastOnQueue('Hello', new PrivateChannel('chat.1'))
    ->catch(fn (Throwable $e) => Log::error('turn failed', ['e' => $e])); // never called