File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -77,15 +77,15 @@ public function suspend(): mixed
77
77
}
78
78
79
79
// Awaiting from {main}.
80
- $ lambda = ($ this ->run )();
80
+ $ result = ($ this ->run )( )();
81
81
82
82
/** @psalm-suppress RedundantCondition $this->pending should be changed when resumed. */
83
83
if ($ this ->pending ) {
84
84
// Should only be true if the event loop exited without resolving the promise.
85
85
throw new \Error ('Scheduler suspended or exited unexpectedly ' );
86
86
}
87
87
88
- return $ lambda () ;
88
+ return $ result ;
89
89
}
90
90
91
91
public function throw (\Throwable $ throwable ): void
Original file line number Diff line number Diff line change @@ -197,4 +197,18 @@ public function testSuspensionWithinQueue(): void
197
197
198
198
self ::assertSame ($ send , $ received );
199
199
}
200
+
201
+ public function testSuspensionThrowingErrorViaInterrupt (): void
202
+ {
203
+ $ suspension = EventLoop::createSuspension ();
204
+ $ error = new \Error ("Test error " );
205
+ EventLoop::queue (static fn () => throw $ error );
206
+ EventLoop::defer (static fn () => $ suspension ->resume ("Value " ));
207
+ try {
208
+ $ suspension ->suspend ();
209
+ self ::fail ("Error was not thrown " );
210
+ } catch (\Throwable $ t ) {
211
+ self ::assertSame ($ error , $ t );
212
+ }
213
+ }
200
214
}
You can’t perform that action at this time.
0 commit comments