framework: Undefined index: laravel_data
- Laravel Version: 8.83.7
- PHP Version: 7.4.28
- Database Driver & Version: MySQL 5.7
Description:
For unknown reason horizon jobs are failing due to this:
ErrorException: Undefined index: laravel_data in PATH_WHERE_CODE_LIVES/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php:972
The code that is causing this:
$pendingRequest = $this->createPendingRequest($headers, $timeout, $clientRequest);
$response = $pendingRequest->get($url, $queryParams); // This is where I exception starts bubbling into the framework.
with the custom function createPendingRequest which is just calling the HTTP facade.
private function createPendingRequest(array $headers, int $timeout, &$clientRequest = null): PendingRequest
{
$options = [
'connect_timeout' => config('guzzle.connect_timeout'),
'timeout' => $timeout,
];
return Http::withHeaders($headers)
->withOptions($options)
->beforeSending(function (ClientRequest $request) use (&$clientRequest) {
$clientRequest = $request;
});
}
Steps To Reproduce:
Happens randomly. But wen it starts, it only stops by doing a horizon:terminate
This is a very hard thing for us to figure out why this is failing inside the framework. If it’s not a bug but a problem on infrastructure level that “laravel_data” would be unknown, I can use some “guidance” or ideas which will cause this to happen.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 20 (8 by maintainers)
Commits related to this issue
- make_build_client_protected Make creation and building of client protected. As per this comment https://github.com/laravel/framework/issues/41872#issuecomment-2095505159 those methdos are intended fo... — committed to func0der/framework by func0der 3 years ago
- make_build_client_protected Make creation and building of client protected. As per this comment https://github.com/laravel/framework/issues/41872#issuecomment-2095505159 those methdos are intended fo... — committed to func0der/framework by func0der 3 years ago
- Make creation and building of client protected. As per this comment https://github.com/laravel/framework/issues/41872#issuecomment-2095505159 those methdos are intended for internal use only. So they... — committed to func0der/framework by func0der 3 years ago
Why is this closed?
This perfectly reproduces the problem even with version 10.48.8.
If the method should not be used, it should be marked as
@internal. As long as it is not marked as such, it is public API of the framework.I understand, but the original problem/bug happend with normal usage of the client (not with those methods you mentioned). Problems happend only in queue environments and after reading blog post from @themsaid regarding strang behaviorus when you’re having memory leaks in the queue I decided to take action on that and as a “result” the issue didn’t happened for me anymore. So my best guess was that the memory issue was responsible for the missing “laravel_data” key in the session for outgoing calls.
the buildClient is not documented anywhere, so i suppose it should not be used
I gave up to try to find the exact reason why it was not set anymore by Laravel. The solution that I posted here is just a workaround and that way I didn’t had the error anymore. But I agree, it should not be “fixed” like that, but prevented in code that that laravel_data was not present.