File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,10 @@ final protected function setTimeout(int $timeout)
196196 {
197197 $ this ->timeout = $ timeout ;
198198
199+ if (isset ($ this ->timeoutId )) {
200+ Loop::cancel ($ this ->timeoutId );
201+ }
202+
199203 $ this ->timeoutId = Loop::delay ($ timeout , function () use ($ timeout ) {
200204 Loop::stop ();
201205 Loop::setErrorHandler (null );
Original file line number Diff line number Diff line change @@ -121,6 +121,16 @@ public function testSetTimeout(): \Generator
121121 $ this ->assertNull (yield delay (250 ));
122122 }
123123
124+ public function testSetTimeoutReplace (): \Generator
125+ {
126+ $ this ->setTimeout (500 );
127+ $ this ->setTimeout (1000 );
128+
129+ yield delay (750 );
130+
131+ $ this ->expectNotToPerformAssertions ();
132+ }
133+
124134 public function testSetTimeoutWithCoroutine (): \Generator
125135 {
126136 $ this ->setTimeout (100 );
You can’t perform that action at this time.
0 commit comments