Skip to content
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

Session store not set on request. but storage type:cache is already seted #305

Open
andrecuellar opened this issue Feb 7, 2022 · 1 comment

Comments

@andrecuellar
Copy link

andrecuellar commented Feb 7, 2022

Hello, I have a Job and command, my job is calling to a service class

Command:

    public function handle()
    {
        \App\Jobs\SyncFranchises::dispatch()->onQueue('sync');
    }

Job:

    public function handle()
    {
        $saveFranchise = new SaveFranchise();
        $saveFranchise->saveFranchise();
    }

service

    public function saveFranchise()
    {
        Forrest::authenticate();
        $productQuery = Forrest::query("SELECT Id,Name,Description,MarketArea__c, LastModifiedDate FROM
        Product2 WHERE Family = 'Lilly CloudRestaurant'");

        foreach ($productQuery['records'] as $product)
        {
            $franchise = new Franchise();
            $franchise->name = $product['Name'];
            $franchise->description = $product['Description'];
            $franchise->min_distance = round($product['MarketArea__c']);
            $franchise->salesforce_id = $product['Id'];
            $franchise->save();
        }
    }

I'm using Forrest::authenticate(); on the service, but I get this error on failed_jobs

RuntimeException: Session store not set on request. in /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Request.php:502
Stack trace:
#0 /var/www/html/vendor/omniphx/forrest/src/Omniphx/Forrest/Providers/Laravel/ForrestServiceProvider.php(38): Illuminate\Http\Request->session()
#1 /var/www/html/vendor/omniphx/forrest/src/Omniphx/Forrest/Providers/BaseServiceProvider.php(93): Omniphx\Forrest\Providers\Laravel\ForrestServiceProvider->getStorage()

My config/forrest.php file has this

'authentication' => env('SF_AUTH_METHOD', 'OAuthJWT'),
'privateKey'     => file_get_contents(storage_path('Area_Check.key')),
'storage'        => [
    'type'          => 'cache', // Options include: 'session', 'cache', 'object'

I have read that with 'storage' => ['type' => 'cache'], it should be solved, but I still have the same problem when executing the command

@omniphx
Copy link
Owner

omniphx commented Feb 11, 2022

Your config/forrest.php should have a username configured as well but I'm not sure why you are getting an error about session store. Especially if you configured your app to use cache instead of session.

Which laravel version are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants