Skip to content

Commit 8b50a3d

Browse files
committed
Only clear connection where it could actually be cleared
1 parent 62a35d7 commit 8b50a3d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/SubscriptionRepository.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ public function clearConnection(string $connectionId): void
5151
],
5252
]);
5353

54-
$this->dynamoDb->batchWriteItem([
55-
'RequestItems' => [
56-
$this->table => collect($response['Items'])->map(fn($item) => [
57-
'DeleteRequest' => [
58-
'Key' => Arr::only($item, ['connectionId', 'channel']),
59-
],
60-
])->toArray(),
61-
],
62-
]);
54+
if (! empty($response['Items'])) {
55+
$this->dynamoDb->batchWriteItem([
56+
'RequestItems' => [
57+
$this->table => collect($response['Items'])->map(fn($item) => [
58+
'DeleteRequest' => [
59+
'Key' => Arr::only($item, ['connectionId', 'channel']),
60+
],
61+
])->toArray(),
62+
],
63+
]);
64+
}
6365
}
6466

6567
public function subscribeToChannel(string $connectionId, string $channel): void

0 commit comments

Comments
 (0)