Please answer these questions before submitting your issue. Thanks!
What did you do? If possible, provide a simple script for reproducing the error.
During autoloading, coroutines switches would lead to a fatal error. As hooks are defined globally while autoload functions are often registered in vendors, it is not easy to manually override autoload functions one by one. I would like to see Swoole disables runtime hooks automatically during autoloading to avoid surprises.
<?php
Co::set(['hook_flags'=> SWOOLE_HOOK_ALL]);
$load = function ($name) {
sleep(1); // or file_get_content('path/to/source.php');
eval('class InexistentClass{}');
};
spl_autoload_register($load);
Co\run(function () {
go(function () {
new InexistentClass;
});
go(function () {
new InexistentClass;
});
});
What did you expect to see?
InexistentClass loaded.
What did you see instead?
Fatal error: Uncaught Error: Class 'InexistentClass' not found in /test.php:13
What version of Swoole are you using (show your php --ri swoole)?
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.4.16
Built => Mar 14 2020 23:18:06
coroutine => enabled
kqueue => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.0.2s 28 May 2019
http2 => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777223/D16777223
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144
What is your machine environment used (including version of kernel & php & gcc) ?
Please answer these questions before submitting your issue. Thanks!
During autoloading, coroutines switches would lead to a fatal error. As hooks are defined globally while autoload functions are often registered in vendors, it is not easy to manually override autoload functions one by one. I would like to see Swoole disables runtime hooks automatically during autoloading to avoid surprises.
InexistentClass loaded.
Fatal error: Uncaught Error: Class 'InexistentClass' not found in /test.php:13
php --ri swoole
)?不相关。