async: await() error in SimpleFiber.php
(Great job with Fibers initiative!) For test purposes I’m refactoring my app with await() function in place of promises-chains. I’ve got an error:
2021-11-29 21:56:23 [EXCEPTION] Error: Value of type null is not callable in ...\vendor\react\async\src\SimpleFiber.php:59
2021-11-29 21:56:23 [EXCEPTION] #0 ...\vendor\react\async\src\functions.php(92): React\Async\SimpleFiber->suspend()
2021-11-29 21:56:23 [EXCEPTION] #1 ...\MessagesProcessor.php(114): React\Async\await(Object(React\Promise\Promise))
It occurs when I try to use async() function. It’s hard to say how to reproduce this bug. In the same call stack, a few promises before, I use a React\Http\Browser with async() function. If I comment this usage (replace to something like resolve(new ResultObject())
) - error doesn’t occur. If I use Browser with promise-style api, the PHP process ends with error:
Process finished with exit code -1073741819 (0xC0000005)
I’m using the newest versions of all packages, ofc PHP 8.1. Do you know what can cause these errors?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (8 by maintainers)
A valid reason I can think of to call
await
in the main fiber is to determine the exit code of the application. Note that the order of things added to the event loop is important as described in @WyriHaximus’s blog.Need to translate this into documentation, but write my thoughts and the outlines of our current plan down at: https://blog.wyrihaximus.net/2021/12/async-and-await-at-the-edge-with-reactphp/
@bartvanhoutte yes, each async will create a new fiber.