Coder Social home page Coder Social logo

Comments (5)

Z3d0X avatar Z3d0X commented on June 22, 2024

Potentially related to #111

from filament-fabricator.

ksimenic avatar ksimenic commented on June 22, 2024

I have the same problem and managed to get to the root of it.

The issue is in Z3d0X\FilamentFabricator\FilamentFabricatorServiceProvider.

    public function packageRegistered(): void
    {
        parent::packageRegistered();

        $this->app->scoped('filament-fabricator', function () {
            return new FilamentFabricatorManager();
        });
    }

Based on the https://laravel.com/docs/10.x/container#binding-scoped

The scoped method binds a class or interface into the container that should only be resolved one time within a given Laravel request / job lifecycle. While this method is similar to the singleton method, instances registered using the scoped method will be flushed whenever the Laravel application starts a new "lifecycle", such as when a Laravel Octane worker processes a new request or when a Laravel queue worker processes a new job:

Because filament-fabricator is registered as scoped it is flushed on every call. When it instantiates new FilamentFabricatorManager this is what happens in the constructor

    public function __construct()
    {
        /** @var Collection<string,string> */
        $pageBlocks = collect([]);

        /** @var Collection<string,string> */
        $layouts = collect([]);

        $this->pageBlocks = $pageBlocks;
        $this->layouts = $layouts;
    }

meaning all previously registered page blocks and layouts will be overwritten by empty collections (removed).

Now this would be fine if bootingPackage() method from Z3d0X\FilamentFabricator\FilamentFabricatorServiceProvider is called, but this happens only once.

This will eventually result in having page blocks and layouts visible on first and N-1 subsequent requests (N = number of workers that you are running octane with), but on the N+1 request they will simply disappear and be gone until you restart octane server.

Solution to this problem is simply changing scoped with singleton but I am not 100% sure of the full implications this might have on the package.

    public function packageRegistered(): void
    {
        parent::packageRegistered();

        $this->app->singleton('filament-fabricator', function () {
            return new FilamentFabricatorManager();
        });
    }

What was the reason of going with scoped instead of singleton in the first place @Z3d0X?

from filament-fabricator.

Z3d0X avatar Z3d0X commented on June 22, 2024

I don't think there was any specific reason for going with scoped instead of singleton.

If singleton works let's change to that. Thanks for investigating this issue.

from filament-fabricator.

plunkettscott avatar plunkettscott commented on June 22, 2024

@Z3d0X any idea when this will be tagged?

from filament-fabricator.

Z3d0X avatar Z3d0X commented on June 22, 2024

v2.0.6 Released with #130

from filament-fabricator.

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.