Skip to content

Commit 8cb036c

Browse files
authored
Handle target destroyed too fast (chrome-php#179)
1 parent 14cf2af commit 8cb036c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Communication/Connection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use HeadlessChromium\Exception\CommunicationException\InvalidResponse;
1919
use HeadlessChromium\Exception\CommunicationException\CannotReadResponse;
2020
use HeadlessChromium\Exception\OperationTimedOut;
21+
use HeadlessChromium\Exception\TargetDestroyed;
2122
use Psr\Log\LoggerAwareInterface;
2223
use Psr\Log\LoggerAwareTrait;
2324
use Psr\Log\LoggerInterface;
@@ -245,6 +246,8 @@ public function createSession($targetId): Session
245246
$response = $this->sendMessageSync(
246247
new Message('Target.attachToTarget', ['targetId' => $targetId])
247248
);
249+
if (empty($response['result']))
250+
throw new TargetDestroyed('The target was destroyed.');
248251
$sessionId = $response['result']['sessionId'];
249252
$session = new Session($targetId, $sessionId, $this);
250253

0 commit comments

Comments
 (0)