-
Notifications
You must be signed in to change notification settings - Fork 297
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
sync_worker_exec_payload: TypeError: fwrite(): Argument #2 ($data) must be of type string, null given #972
Comments
I realized I had written it wrong. setContent has been overwritted https://github.com/laravel/framework/blob/11.x/src/Illuminate/Http/Response.php#L51 Maybe we can copy symfony? https://github.com/symfony/http-foundation/blob/7.2/Response.php#L420 public function setContent($content)
{
// $this->original = $content;
$this->original = $content ?? '';
} |
Update I also found dingo overwrite the response '$this->original' is nullable https://github.com/dingo/api/blob/master/src/Http/Response.php#L206 https://github.com/laravel/framework/blob/11.x/src/Illuminate/Http/ResponseTrait.php#L60 public function setContent($content)
{
if (! empty($content) && is_object($content) && ! $this->shouldBeJson($content)) {
$this->original = $content; // <-----nullable
return $this;
}
try {
return parent::setContent($content); // <------do $this->content = $content ?? '';
} catch (UnexpectedValueException $exception) {
$this->original = $content;
return $this;
}
} |
I believe we should update Illuminate/Http/Response.php#L51 but you need to report the issue to |
`$content` is set to `null` 1. Symfony set the content to `null` for `response()->noContent()` https://github.com/symfony/http-foundation/blob/e88a66c3997859532bc2ddd6dd8f35aba2711744/Response.php#L246-L249 2. This cause issue with PSR-7 HTTP Stream in Octane fixed laravel/octane#972 Signed-off-by: Mior Muhammad Zaki <[email protected]>
@675076143 Can you test if laravel/framework#53872 worked for you? |
It works 😊 |
Octane Version
1.5.6
Laravel Version
8.83.29
PHP Version
8.1.3
What server type are you using?
Roadrunner
Server Version
2.12.3
Database Driver & Version
No response
Description
Just
response()->noContent()
I will get status 500, and worker stop.sync_worker_exec_payload: TypeError: fwrite(): Argument #2 ($data) must be of type string, null given in vendor/laminas/laminas-diactoros/src/Stream.php:234
This is because the use of
declare(strict_types=1);
inlaminas/laminas-diactoros/src/Stream.php
So
fwrite($stream, null)
throw error.And In
symfony/http-foundation
When the response status is 204, the content will be set to null..😭
https://github.com/symfony/http-foundation/blob/7.2/Response.php#L1259
https://github.com/symfony/http-foundation/blob/7.2/Response.php#L247
Steps To Reproduce
The text was updated successfully, but these errors were encountered: