diff --git a/lib/Sync/functions.php b/lib/Sync/functions.php index d5ba431..9e4178e 100644 --- a/lib/Sync/functions.php +++ b/lib/Sync/functions.php @@ -5,8 +5,14 @@ use Amp\Serialization\SerializationException as SerializerException; if (!\class_exists(SerializationException::class)) { - // Alias must be defined in an always-loaded file as catch blocks do not trigger the autoloader. - \class_alias(SerializerException::class, SerializationException::class); + // Wrap definition in error handler to avoid apparently PHP bug with preloading, see amphp/parallel#159 + set_error_handler(function (): bool { return true; }); + try { + // Alias must be defined in an always-loaded file as catch blocks do not trigger the autoloader. + \class_alias(SerializerException::class, SerializationException::class); + } finally { + restore_error_handler(); + } } /**