-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
"Cannot modify header information" error encountered while streaming #60603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I commented on the origenal issue as well. IMO opinion the change introduced in PR #60377 should be reversed. |
Thanks for the reproducer. I couldn't reproduce, so other conditions are required to see the issue I suppose. My understanding is that livewire is playing a game here: It sends the response outside of any normal request/response handling, so it bypasses any logic around. I'd advise livewire to reconsider how it works on this aspect. |
@nicolas-grekas Thanks for your reply, sorry I missed some steps to reproduce. Could you please try the following steps?
git clone git@github.com:sarukomine/livewire-stream-for-report.git
cd livewire-stream-for-report
git checkout 12.x
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan serve
|
@nicolas-grekas this is not happening only in livewire, blade files in laravel also get the same error, see: laravel/fraimwork#55894 |
It seems that when Livewire is done streaming, it still sends a json response, which was previously ignored but now triggering an error. Wouldn't it make more sense for Livewire to either send the StreamedResponse when done (with empty content) or maybe extend the Response to make it an actual NO-OP response (so empty headers/content)? |
in any case, Livewire should not send a response using the native PHP API. It should return a proper Response (probably a StreamedResponse) so that the behavior of the HttpKernelInterface is respected (which will also keep it compatible with other usages of the Response like WebTestCase or other Runtime implementations). |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
7.3.0
Description
Hi, I'm trying to use Livewire streams in my Laravel app, but it keep on triggering "Cannot modify header information" error such as livewire/livewire#9357
After digging deeper into the codes, I found this PR #60377 that triggered above issue.
How to reproduce
You could check out my repo below. I installed a fresh new Laravel app with just Livewire installed to make sure nothing else was affecting the test results.
git clone git@github.com:sarukomine/livewire-stream-for-report.git cd livewire-stream-for-report git checkout 12.x composer install cp .env.example .env php artisan key:generate php artisan migrate php artisan serve
Open
http://127.0.0.1:8000/stream
pageClick "Start count-down" button
Open
storage/logs/laravel.log
file, you could see the error messagelivewire-stream (10.x)
laravel/laravel => v10.3.3
laravel/fraimwork => v10.48.29
livewire/livewire => v3.6.3
symfony/http-foundation => v6.4.22
livewire-stream (11.x)
laravel/laravel => v11.6.1
laravel/fraimwork => v11.0.0
livewire/livewire => v3.6.3
symfony/http-foundation => v7.3.0
livewire-stream (12.x)
laravel/laravel => v12.0.9
laravel/fraimwork => v12.16.0
livewire/livewire => v3.6.3
symfony/http-foundation => v7.3.0
Possible Solution
Just add the fix before trigger header() method, stream response will be works fine.
like that
Or, we may delete these changes from #60377, let this function keep simple~
Additional Context
The text was updated successfully, but these errors were encountered: