Skip to content

Commit df07f78

Browse files
committed
Properly rethrow Websocket handler errors into Reactor
1 parent f88aebf commit df07f78

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/Rfc6455Endpoint.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function __construct($socket, Websocket $application, array $headers = []
8282
$this->socket = $socket;
8383
$this->parser = $this->parser([$this, "onParse"]);
8484
$this->writeWatcher = \Amp\onWritable($socket, [$this, "onWritable"], $options = ["enable" => false]);
85-
\Amp\resolve($this->tryAppOnOpen($headers));
85+
\Amp\resolve($this->tryAppOnOpen($headers))->when(function($e){ if ($e) throw $e; });
8686
}
8787

8888
private function tryAppOnOpen($headers) {
@@ -212,7 +212,7 @@ private function onParsedData(array $parseResult) {
212212
if (!$this->msgPromisor) {
213213
$this->msgPromisor = new Deferred;
214214
$msg = new Message($this->msgPromisor->promise());
215-
\Amp\resolve($this->tryAppOnData($msg));
215+
\Amp\resolve($this->tryAppOnData($msg))->when(function($e) { if ($e) throw $e; });
216216
}
217217

218218
$this->msgPromisor->update($data);
@@ -249,7 +249,7 @@ private function onParsedError(array $parseResult) {
249249
}
250250

251251
if (!$this->closedAt) {
252-
$this->doClose($code, $msg);
252+
$this->doClose($code, $msg)->when(function($e){ if ($e) throw $e; });
253253
}
254254
}
255255
}
@@ -266,7 +266,7 @@ public function onReadable($watcherId, $socket) {
266266
$this->closedAt = $this->now;
267267
$code = Code::ABNORMAL_CLOSE;
268268
$reason = "Client closed underlying TCP connection";
269-
\Amp\resolve($this->tryAppOnClose($code, $reason));
269+
\Amp\resolve($this->tryAppOnClose($code, $reason))->when(function($e){ if ($e) throw $e; });
270270
} else {
271271
$this->closeTimeout = null;
272272
}
@@ -406,7 +406,7 @@ public function sendBinary($data) {
406406
}
407407

408408
public function close($code = Code::NORMAL_CLOSE, $reason = "") {
409-
$this->doClose($code, $reason);
409+
$this->doClose($code, $reason)->when(function($e){ if ($e) throw $e; });
410410
}
411411

412412
public function getInfo() {

0 commit comments

Comments
 (0)