Giter Club home page Giter Club logo

Comments (8)

Baldinof avatar Baldinof commented on September 12, 2024

Normally sessions should work out of the box now with Symfony.

What version of Symfony are you using?

Can you reproduce on a fresh Symfony install?

from roadrunner-bundle.

FluffyDiscord avatar FluffyDiscord commented on September 12, 2024

Using symfony 6.3 I have hard time reproducing it on production too, but it does happen as clients reported this multiple times and today that happened to me too

from roadrunner-bundle.

Baldinof avatar Baldinof commented on September 12, 2024

Are you using a custom session handler?

from roadrunner-bundle.

FluffyDiscord avatar FluffyDiscord commented on September 12, 2024

this is the whole framework.yaml

# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
    http_method_override: false
    trusted_proxies: '127.0.0.1/8,REMOTE_ADDR,SERVER_NAME'
    trusted_headers: [ 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix' ]
    secret: '%env(APP_SECRET)%'
    handle_all_throwables: true
    #csrf_protection: true
    #http_method_override: true

    # Enables session support. Note that the session will ONLY be started if you read or write from it.
    # Remove or comment this section to explicitly disable session support.
    session:
        storage_factory_id: session.storage.factory.native
        handler_id: session.handler.native_file
        save_path: '%kernel.project_dir%/sessions/%kernel.environment%'
        cookie_secure: auto
        cookie_samesite: lax
        cookie_lifetime: 31536000 # one year in seconds

    #esi: true
    #fragments: true
    php_errors:
        log: true

from roadrunner-bundle.

webspec2012 avatar webspec2012 commented on September 12, 2024

Maybe this is also related to my problem?

#114

from roadrunner-bundle.

Baldinof avatar Baldinof commented on September 12, 2024

I'll try to give it some time, it's strange 😬

from roadrunner-bundle.

Baldinof avatar Baldinof commented on September 12, 2024

I tried to had a look with no luck.

I tried on a fresh project, using in-memory or doctrine as user storage and everything was working fine (with one or many workers).

Are you able to provide a reproducer repository? I would gladely help as it seems pretty serious but I'm not able to reproduce it on a fresh project.

from roadrunner-bundle.

FluffyDiscord avatar FluffyDiscord commented on September 12, 2024

I have added the following middleware, and so far it seems fine. Since the ServicesResetter does not register all services that can be reset (my own, internal symfony's, bundles, eg.) combining it with iterating over the private container services seems to finally work as intended.

<?php

namespace App\RoadRunner\Middleware;

use Baldinof\RoadRunnerBundle\Http\MiddlewareInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Contracts\Service\ResetInterface;

readonly class ServiceReSetterMiddleware implements MiddlewareInterface
{
    public function __construct(
        #[Autowire("@service_container")]
        private ContainerInterface $container,

        #[Autowire("@services_resetter")]
        private ServicesResetter   $servicesResetter,
    )
    {
    }

    public function process(Request $request, HttpKernelInterface $next): \Iterator
    {
        yield $next->handle($request);

        $this->servicesResetter->reset();

        $ref = new \ReflectionClass($this->container);
        $prop = $ref->getProperty("privates");
        $services = $prop->getValue($this->container);

        foreach ($services as $service) {
            if ($service instanceof ResetInterface) {
                $service->reset();
            }
        }
    }
}

I would live to add reproducer repo, but I cant myself easily reproduce it, it was really random.

from roadrunner-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.