@@ -1437,19 +1437,13 @@ private function shutdown(?HttpException $reason = null, ?int $lastId = null): v
14371437 return ;
14381438 }
14391439
1440- $ reason ??= new SocketException (
1441- "The HTTP/2 connection from ' " . $ this ->socket ->getLocalAddress () . "' to ' "
1442- . $ this ->socket ->getRemoteAddress () . "' closed unexpectedly " ,
1443- Http2Parser::INTERNAL_ERROR ,
1444- );
1445-
14461440 if ($ this ->settings !== null ) {
14471441 $ message = "Connection closed before HTTP/2 settings could be received " ;
14481442 $ this ->settings ->error (new SocketException ($ message , 0 , $ reason ));
14491443 $ this ->settings = null ;
14501444 }
14511445
1452- $ previous = $ reason ->getPrevious ();
1446+ $ previous = $ reason? ->getPrevious();
14531447 $ previous = $ previous instanceof Http2ConnectionException ? $ previous : null ;
14541448
14551449 $ code = $ previous ?->getCode() ?? Http2Parser::GRACEFUL_SHUTDOWN ;
@@ -1470,6 +1464,7 @@ private function shutdown(?HttpException $reason = null, ?int $lastId = null): v
14701464 $ this ->writeFrame (Http2Parser::GOAWAY , data: \pack ('NN ' , 0 , $ code ) . $ message )->ignore ();
14711465
14721466 foreach ($ this ->streams as $ id => $ stream ) {
1467+ $ reason ??= $ this ->makeDefaultShutdownReason ();
14731468 $ this ->releaseStream ($ id , $ reason , unprocessed: false );
14741469 }
14751470
@@ -1481,10 +1476,20 @@ private function shutdown(?HttpException $reason = null, ?int $lastId = null): v
14811476 continue ;
14821477 }
14831478
1479+ $ reason ??= $ this ->makeDefaultShutdownReason ();
14841480 $ this ->releaseStream ($ id , $ reason , unprocessed: true );
14851481 }
14861482 }
14871483
1484+ private function makeDefaultShutdownReason (): SocketException
1485+ {
1486+ return new SocketException (
1487+ "The HTTP/2 connection from ' " . $ this ->socket ->getLocalAddress () . "' to ' "
1488+ . $ this ->socket ->getRemoteAddress () . "' closed unexpectedly " ,
1489+ Http2Parser::INTERNAL_ERROR ,
1490+ );
1491+ }
1492+
14881493 /**
14891494 * @psalm-return list<list{string, string}>
14901495 *
0 commit comments