You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I rewrote some endpoints on my laravel app to use the streamJson function to generate the API response (to preserve some memory on large responses). After the changes the scribe generate command on these GET endpoints results with status: 200, but empty content: ''
With curl/postman the endpoint works as before (same content with the same content-type header, etc.)
Eg. code changes:
old: return $query->get();
new:
return response()->streamJson($this->yieldResults(query));
function yieldResults($query): Generator {
foreach ($query->lazy() as $item) yield $item;
}
I dig into the scribe source and found that in Extracting\Strategies\Responses\ResponseCalls.php the response of the $kernel->handle($request) call with the old code is a Illuminate\Http\JsonResponse with the content as expected. However with my new code the response is Symfony\Component\HttpFoundation\StreamedJsonResponse with #content: ? string and #streamed: false. The details of the response object is attached in the file.
I don't think there's any "cause" from your end. A streamed response needs to be handled differently from a regular response. A regular response returns the entire contents at once, but a streamed response does not immediately render its content. The response calls strategy probably needs to check if the response was streamed and force all the content to be rendered. PRs welcome.
Scribe version
4.39.0
PHP version
8.3
Laravel version
11.41.3
Scribe config
What happened?
I rewrote some endpoints on my laravel app to use the streamJson function to generate the API response (to preserve some memory on large responses). After the changes the scribe generate command on these GET endpoints results with status: 200, but empty content: ''
With curl/postman the endpoint works as before (same content with the same content-type header, etc.)
Eg. code changes:
old:
return $query->get();
new:
I dig into the scribe source and found that in Extracting\Strategies\Responses\ResponseCalls.php the response of the $kernel->handle($request) call with the old code is a Illuminate\Http\JsonResponse with the content as expected. However with my new code the response is Symfony\Component\HttpFoundation\StreamedJsonResponse with #content: ? string and #streamed: false. The details of the response object is attached in the file.
response.txt
What can be the cause? Did I miss some config settings?
Docs
The text was updated successfully, but these errors were encountered: