File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55use Evenement \EventEmitter ;
66use React \EventLoop \LoopInterface ;
7- use React \Stream \WritableStreamInterface ;
87
98/** @event full-drain */
109class Buffer extends EventEmitter implements WritableStreamInterface
@@ -83,8 +82,8 @@ public function close()
8382
8483 public function handleWrite ()
8584 {
86- if (!is_resource ($ this ->stream ) || ( ' generic_socket ' === $ this -> meta [ ' stream_type ' ] && feof ( $ this -> stream )) ) {
87- $ this ->emit ('error ' , array (new \RuntimeException ('Tried to write to closed or invalid stream. ' )));
85+ if (!is_resource ($ this ->stream )) {
86+ $ this ->emit ('error ' , array (new \RuntimeException ('Tried to write to invalid stream. ' ), $ this ));
8887
8988 return ;
9089 }
@@ -107,6 +106,12 @@ public function handleWrite()
107106 return ;
108107 }
109108
109+ if (0 === $ sent && feof ($ this ->stream )) {
110+ $ this ->emit ('error ' , array (new \RuntimeException ('Tried to write to closed stream. ' ), $ this ));
111+
112+ return ;
113+ }
114+
110115 $ len = strlen ($ this ->data );
111116 if ($ len >= $ this ->softLimit && $ len - $ sent < $ this ->softLimit ) {
112117 $ this ->emit ('drain ' );
You can’t perform that action at this time.
0 commit comments