Giter VIP home page Giter VIP logo

Comments (5)

danbka33 avatar danbka33 commented on July 22, 2024 2

To fix this issue just add SubscriptionRegistry::class to octane config octane.warm.

Description of this configuration section.

    /*
    |--------------------------------------------------------------------------
    | Warm / Flush Bindings
    |--------------------------------------------------------------------------
    |
    | The bindings listed below will either be pre-warmed when a worker boots
    | or they will be flushed before every new request. Flushing a binding
    | will force the container to resolve that binding again when asked.
    |
    */

After adding this SubscriptionRegistry to the list of warms, the problem went away.

 'warm' => [
        ...Octane::defaultServicesToWarm(),
        Nuwave\Lighthouse\Subscriptions\SubscriptionRegistry::class,
    ],

It is worth updating the documentation and creating a section on how to configure lighthouse to work with laravel octane, or using internal methods to change the laravel octane configuration.

I'm still not entirely sure whether the decision is correct or whether there is some side effect from adding this class to the list of "warm".

from lighthouse.

spawnia avatar spawnia commented on July 22, 2024 1

I propose an addition to the docs in #2575, does this look right?

from lighthouse.

danbka33 avatar danbka33 commented on July 22, 2024

The error only appears when used together with laravel octane (swoole). There is no error when using php-fpm.

from lighthouse.

danbka33 avatar danbka33 commented on July 22, 2024

Add dump to constuctor of SubscriptionRegistry

dump('subscription registry new instance: ' . spl_object_hash($this));

Got 2 instances

subscription registry new instance: 00000000000054960000000000000000
subscription registry new instance: 00000000000007ea0000000000000000

First request i got

array:1 [ // $subscriptions dump
  0 => "scheduleUpdated"
]
spl_object_hash of SubscriptionRegistry: 00000000000007ea0000000000000000

Second and future requests

array:0 [] // $subscriptions dump
00000000000054960000000000000000

In the second and etc requests, subscription registration is not called...

from lighthouse.

danbka33 avatar danbka33 commented on July 22, 2024

Based on the explanations in this article, this appears to be a solution to the problem.

https://divinglaravel.com/laravel-octane-bootstrapping-the-application-and-handling-requests

Only singletons that are resolved during the application bootstrapping will persist between requests. Singletons that are resolved during request handling will be registered in the sandbox container, this container is destroyed after handling the request.
To persist singletons between requests, you can either resolve them in your service providers or add them to the warm array inside the Octane configuration file

But the explanations sound a little strange, here singleton is set in the service provider, which in theory should be a marker for laravel octane to keep it persistent...

$this->app->singleton(SubscriptionRegistry::class);

from lighthouse.

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.