runtime icon indicating copy to clipboard operation
runtime copied to clipboard

StreamedResponse not supported in Roadrunner

Open alexander-schranz opened this issue 3 years ago • 4 comments

More as a reference here currently there is no way to use a StreamedResponse inside roadrunner. This is because things output with echo, var_dump, flush or any other php internal method is not supported by roadrunner and is in this case ignored.

The issue on the roadrunner side is here: https://github.com/spiral/roadrunner/issues/2.

alexander-schranz avatar May 21 '21 20:05 alexander-schranz

Hi, I think I can give a little help here.

RoadRunner does not support streaming the responses, it means PSR responses streams are just consumed entirely and sent as one payload to RR.

StreamedResponse are well handled on the PsrHttpFactory side.

The problem is that Symfony setups a StreamedResponseListener which consumes the stream before PsrHttpFactory.

I handled this by disabling the Symfony listener when running in RR: https://github.com/Baldinof/roadrunner-bundle/blob/2.x/src/Integration/Symfony/StreamedResponseListener.php

Baldinof avatar Jun 02 '21 14:06 Baldinof

FWIW, StreamedResponse doesn't seem to work with swoole either :thinking:

Errata: bitten by StreamedResponseListener, which operates also under swoole :|

Ocramius avatar Feb 14 '22 13:02 Ocramius

Adding here a reference to https://github.com/php-runtime/runtime/pull/116 as when implementing this for roadrunner we should also keep that in mind.

alexander-schranz avatar Feb 21 '22 10:02 alexander-schranz

Looks good that roadrunner 2.9 will bring us streaming responses: https://github.com/roadrunner-server/roadrunner/issues/923#issuecomment-1069065147

alexander-schranz avatar Mar 16 '22 12:03 alexander-schranz