1818use Spiral \RoadRunner \EnvironmentInterface ;
1919use Spiral \RoadRunner \Payload ;
2020use Spiral \RoadRunner \Worker ;
21- use Symfony \Component \VarDumper \Dumper \CliDumper ;
2221use Temporal \Exception \ProtocolException ;
2322use Temporal \Exception \TransportException ;
2423use Spiral \RoadRunner \WorkerInterface as RoadRunnerWorker ;
@@ -47,7 +46,6 @@ public function __construct(RoadRunnerWorker $worker)
4746 {
4847 $ this ->worker = $ worker ;
4948 $ this ->codec = new JsonCodec ();
50- $ this ->bootStdoutHandlers ();
5149 }
5250
5351 /**
@@ -67,9 +65,7 @@ public static function create(EnvironmentInterface $env = null): HostConnectionI
6765 public function waitBatch (): ?CommandBatch
6866 {
6967 /** @var Payload $payload */
70- $ payload = $ this ->interceptErrors (
71- fn () => $ this ->worker ->waitPayload ()
72- );
68+ $ payload = $ this ->worker ->waitPayload ();
7369
7470 if ($ payload === null ) {
7571 return null ;
@@ -107,71 +103,6 @@ public function error(\Throwable $error): void
107103 }
108104 }
109105
110- /**
111- * @return $this
112- */
113- private function bootStdoutHandlers (): self
114- {
115- // symfony/var-dumper interceptor
116- if (\class_exists (CliDumper::class)) {
117- CliDumper::$ defaultOutput = 'php://stderr ' ;
118- }
119-
120- // Intercept all output messages
121- \ob_start (fn (string $ chunk ) => $ this ->write ($ chunk ), 10 * 1024 );
122-
123- // Intercept all exceptions
124- \set_exception_handler (fn (\Throwable $ e ) => $ this ->writeException ($ e ));
125-
126- // Intercept all errors
127- \set_error_handler (
128- function (int $ code , string $ message , string $ file , int $ line ): void {
129- $ this ->writeException (
130- new \ErrorException ($ message , $ code , $ code , $ file , $ line )
131- );
132- }
133- );
134-
135- return $ this ;
136- }
137-
138- /**
139- * @param string $message
140- */
141- private function write (string $ message ): void
142- {
143- \file_put_contents ('php://stderr ' , $ message );
144- }
145-
146- /**
147- * @param \Throwable $e
148- */
149- private function writeException (\Throwable $ e ): void
150- {
151- $ this ->write ((string )$ e );
152- }
153-
154- /**
155- * @param \Closure $expr
156- * @return mixed
157- */
158- private function interceptErrors (\Closure $ expr )
159- {
160- $ handler = static function (int $ code , string $ message , string $ file , int $ line ): void {
161- $ error = new \ErrorException ($ message , $ code , $ code , $ file , $ line );
162-
163- throw new TransportException ($ message , $ code , $ error );
164- };
165-
166- \set_error_handler ($ handler );
167-
168- try {
169- return $ expr ();
170- } finally {
171- \restore_error_handler ();
172- }
173- }
174-
175106 /**
176107 * @param JsonHeaders|null $headers
177108 * @return array<string, string>
0 commit comments