symfony-bridge icon indicating copy to clipboard operation
symfony-bridge copied to clipboard

When using bridge runtime directly, it breaks easyadminbundle : Unable to add global "ea" as the runtime or the extensions have already been initialized

Open allan-simon opened this issue 3 years ago • 8 comments

With this error , https://github.com/EasyCorp/EasyAdminBundle/issues/3715#issuecomment-999616605

(the work around seems to work)

I think it's because the process is kept alive so some stuff are kept initialized and not cleaned across request ?

allan-simon avatar Feb 16 '22 08:02 allan-simon

I think it's because the process is kept alive so some stuff are kept initialized and not cleaned across request ?

Yes, that means that EasyAdmin is incompatible with keeping the process alive. So your options seem to be:

  • don't use EasyAdmin
  • find a way to fix EasyAdmin
  • don't keep the PHP process alive (don't use BREF_LOOP_MAX)

mnapoli avatar Feb 16 '22 18:02 mnapoli

ok make sense, to the extent of your knowledge, there's no way to have a safety on our side/bref side , to force clean before and/or after a request ? (like unset global variables etc. ) ?

allan-simon avatar Feb 16 '22 20:02 allan-simon

The safety on Bref side is not using BREF_LOOP_MAX 😅

There's no way to know what needs cleanup and what doesn't, that is up to the library to decide. That's for the same reason that Symfony provides some tools to make it easier for you to handle such cases but can't handle it in a generic way that would make all code compatible with things like roadrunner, swoole and the likes.

t-richard avatar Feb 17 '22 07:02 t-richard

@allan-simon why don't you use the standard approach with the FPM layer?

It seems like your application is not compatible with keeping the process alive, and I'd like to understand why you are trying to go that route in that case.

mnapoli avatar Feb 18 '22 12:02 mnapoli

@mnapoli it seems to come with a significant performance improvement and stack simplification , so why not ?

why did you try to create bref though php is not by default compatible with AWS Lambda ? :)

allan-simon avatar Feb 18 '22 12:02 allan-simon

@mnapoli I'm revisiting this issue but now I know the "recipe" to solve it

  1. short term: in my codebase decorate services that are problematic and make them implement the kernel.reset tag
  2. long term: try to backport that directly in said libraries

I'm just missing one piece how do I test easily locally this use case using the bref cli and/or docker containers ?

i.e just changing the env variable for the bref/php-81-fpm-dev:2 containers to

        'HANDLER' => 'App\\Kernel',
        'DOCUMENT_ROOT' => 'public',
        'BREF_LOOP_MAX' => '1000',
        'BREF_BINARY_RESPONSES' => '1',

does not seem enough

allan-simon avatar Oct 26 '23 00:10 allan-simon

Check out https://bref.sh/docs/local-development/event-driven-functions#api-gateway-local-development

mnapoli avatar Oct 26 '23 08:10 mnapoli

ah thanks I missed the link to https://github.com/brefphp/dev-server

allan-simon avatar Oct 26 '23 08:10 allan-simon