swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.47k stars 3.16k forks source link

http事件下swoole 与原生Exception 序列化 冲突 #5496

Closed LIngMax closed 2 months ago

LIngMax commented 2 months ago

Please answer these questions before submitting your issue.

var_dump(serialize(new Exception("fasfasdfad")));#普通环境下执行正常

#http事件下swoole  抛出异常 is not allowed 
$server->on('request', function ($request, $response){serialize(new Exception("fasfasdfad"));@$response->end("啊哈哈哈哈");});

一旦放到 http事件下 马上抛出异常

Serialization of 'Swoole\Http\Request' is not allowed 

swoole扩展不支持序列化的对象  

不可序列化输出警告/不可序列化不输出警告/不可序列化抛出异常

 由开发者控制这样?
  1. What did you do? If possible, provide a simple script for reproducing the error.

Serialization of 'Swoole\Http\Request' is not allowed

  1. What version of Swoole are you using (show your php --ri swoole)? 5.1.3
matyhtf commented 2 months ago

Exception 带上下文,包含了 Swoole 的资源,不支持序列化。而直接在外面,上下文是空的,可以序列化