Skip to content

response()->stream() params inconsistent with Symfony, breaks Livewire #55831

Closed
@woodseowl

Description

@woodseowl

Laravel Version

12.15.0

PHP Version

8.3

Database Driver & Version

No response

Description

In v12.15.0 release, Illuminate/Routing/ResponseFactory::stream() (i.e. response()->stream()) had a change from directly returning a new Symfony StreamedResponse to performing other actions first and then instantiating the StreamedResponse. The Symfony StreamedResponse parameters can take a null "$callable" value, so passing null in for response()->stream() was possible before v12.15.0 but not after, due to the introduced code.

While the signature of ResponseFactory::stream() does not indicate that null is allowed for the $callable parameter, it worked before v12.15.0 and the Symfony StreamedResponse that it wraps accepts null, so it seems more like an oversight than truly intended requirement to pass the $callable.

I'm reporting this because it breaks streaming in Livewire. Livewire calls response()->stream() explicitly with a null value for $callable (see Features/SupportStreaming/SupportStreaming line 22). Granted, this is a Livewire error for not adhering to the function signature, but it may affect other applications that similarly were passing null to response()->stream() and successfully getting a streamed response.

Steps To Reproduce

v12.14.1:

$ php artisan tinker
Psy Shell v0.12.8 (PHP 8.3.15 — cli) by Justin Hileman
> response()->stream(null)->getStatusCode()
= 200

v12.15.0:

$ php artisan tinker
Psy Shell v0.12.8 (PHP 8.3.15 — cli) by Justin Hileman
> response()->stream(null)->getStatusCode()
ReflectionException  Function () does not exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions