Skip to content

Pretty URL Router fails to clear cache if ENV var only exists in PROD #6509

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

Open
KDederichs opened this issue Nov 6, 2024 · 14 comments · May be fixed by #6883
Open

Pretty URL Router fails to clear cache if ENV var only exists in PROD #6509

KDederichs opened this issue Nov 6, 2024 · 14 comments · May be fixed by #6883

Comments

@KDederichs
Copy link
Contributor

Describe the bug
Pretty URL router doesn't seem to like env vars that are stored in secrets (https://symfony.com/doc/current/configuration/secrets.html). When enabling the new router deploys will fail with the error below.
To Reproduce

Inject a Service that relies on an env that's stored in a secret into a CRUD controller via constructor.

(OPTIONAL) Additional context

[production] You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.
[production] Installing dependencies from lock file (including require-dev)
[production] Verifying lock file contents can be installed on current platform.
[production] Package operations: 241 installs, 0 updates, 0 removals
[production] - Downloading symfony/runtime (v7.1.7)
[production] - Downloading symfony/http-foundation (v7.1.7)
[production] - Downloading symfony/var-dumper (v7.1.7)
[production] - Downloading symfony/error-handler (v7.1.7)
[production] - Downloading symfony/http-kernel (v7.1.7)
[production] - Downloading symfony/config (v7.1.7)
[production] - Downloading symfony/http-client (v7.1.7)
[production] - Downloading symfony/console (v7.1.7)
[production] - Downloading doctrine/persistence (3.4.0)
[production] - Downloading composer/ca-bundle (1.5.3)
[production] - Downloading symfony/cache (v7.1.7)
[production] - Downloading doctrine/data-fixtures (1.8.0)
[production] - Downloading symfony/validator (v7.1.7)
[production] - Downloading symfony/security-http (v7.1.7)
[production] - Downloading symfony/intl (v7.1.7)
[production] - Downloading easycorp/easyadmin-bundle (v4.14.1)
[production] - Downloading lcobucci/jwt (5.4.1)
[production] - Downloading giggsey/locale (2.7.0)
[production] - Downloading goetas-webservices/xsd-reader (0.4.7)
[production] - Downloading symfony/process (v7.1.7)
[production] - Downloading nesbot/carbon (3.8.1)
[production] - Downloading giggsey/libphonenumber-for-php (8.13.49)
[production] - Downloading php-http/mock-client (1.6.1)
[production] - Downloading php-http/logger-plugin (1.4.0)
[production] - Downloading phpdocumentor/type-resolver (1.9.0)
[production] - Downloading phpdocumentor/reflection-docblock (5.5.0)
[production] - Downloading phpstan/phpstan-doctrine (1.5.5)
[production] - Downloading rector/rector (1.2.9)
[production] - Downloading sentry/sentry (4.10.0)
[production] - Downloading symfony/rate-limiter (v7.1.7)
[production] - Downloading symfony/web-profiler-bundle (v7.1.7)
[production] - Downloading composer/composer (2.8.2)
[production] - Downloading zenstruck/assert (v1.5.1)
[production] - Downloading behat/mink (v1.12.0)
[production] - Downloading zenstruck/browser (v1.9.1)
[production] - Downloading zenstruck/foundry (v2.2.2)
[production] - Installing composer/package-versions-deprecated (1.11.99.5): Extracting archive
[production] - Installing php-http/discovery (1.20.0): Extracting archive
[production] - Installing symfony/flex (v2.4.7): Extracting archive
[production] - Installing symfony/runtime (v7.1.7): Extracting archive
[production] - Installing willdurand/negotiation (3.1.0): Extracting archive
[production] - Installing psr/link (2.0.1): Extracting archive
[production] - Installing symfony/web-link (v7.1.6): Extracting archive
[production] - Installing symfony/translation-contracts (v3.5.0): Extracting archive
[production] - Installing symfony/deprecation-contracts (v3.5.0): Extracting archive
[production] - Installing symfony/serializer (v7.1.6): Extracting archive
[production] - Installing psr/container (2.0.2): Extracting archive
[production] - Installing symfony/type-info (v7.1.6): Extracting archive
[production] - Installing symfony/polyfill-mbstring (v1.31.0): Extracting archive
[production] - Installing symfony/polyfill-intl-normalizer (v1.31.0): Extracting archive
[production] - Installing symfony/polyfill-intl-grapheme (v1.31.0): Extracting archive
[production] - Installing symfony/string (v7.1.6): Extracting archive
[production] - Installing symfony/property-info (v7.1.6): Extracting archive
[production] - Installing symfony/property-access (v7.1.6): Extracting archive
[production] - Installing symfony/polyfill-php83 (v1.31.0): Extracting archive
[production] - Installing symfony/http-foundation (v7.1.7): Extracting archive
[production] - Installing psr/event-dispatcher (1.0.0): Extracting archive
[production] - Installing symfony/event-dispatcher-contracts (v3.5.0): Extracting archive
[production] - Installing symfony/event-dispatcher (v7.1.6): Extracting archive
[production] - Installing symfony/var-dumper (v7.1.7): Extracting archive
[production] - Installing psr/log (3.0.2): Extracting archive
[production] - Installing symfony/error-handler (v7.1.7): Extracting archive
[production] - Installing symfony/http-kernel (v7.1.7): Extracting archive
[production] - Installing psr/cache (3.0.0): Extracting archive
[production] - Installing doctrine/inflector (2.0.10): Extracting archive
[production] - Installing api-platform/core (v4.0.6): Extracting archive
[production] - Installing symfony/var-exporter (v7.1.6): Extracting archive
[production] - Installing symfony/service-contracts (v3.5.0): Extracting archive
[production] - Installing symfony/dependency-injection (v7.1.6): Extracting archive
[production] - Installing symfony/filesystem (v7.1.6): Extracting archive
[production] - Installing symfony/config (v7.1.7): Extracting archive
[production] - Installing symfony/http-client-contracts (v3.5.0): Extracting archive
[production] - Installing symfony/http-client (v7.1.7): Extracting archive
[production] - Installing async-aws/core (1.22.1): Extracting archive
[production] - Installing async-aws/async-aws-bundle (1.12.3): Extracting archive
[production] - Installing psr/http-message (2.0): Extracting archive
[production] - Installing aws/aws-php-sns-message-validator (1.9.0): Extracting archive
[production] - Installing symfony/console (v7.1.7): Extracting archive
[production] - Installing doctrine/event-manager (2.0.1): Extracting archive
[production] - Installing doctrine/persistence (3.4.0): Extracting archive
[production] - Installing doctrine/lexer (3.0.1): Extracting archive
[production] - Installing doctrine/instantiator (2.0.0): Extracting archive
[production] - Installing doctrine/deprecations (1.1.3): Extracting archive
[production] - Installing doctrine/dbal (4.2.1): Extracting archive
[production] - Installing doctrine/collections (2.2.2): Extracting archive
[production] - Installing doctrine/orm (3.3.0): Extracting archive
[production] - Installing beberlei/doctrineextensions (v1.5.0): Extracting archive
[production] - Installing behat/transliterator (v1.5.0): Extracting archive
[production] - Installing composer/ca-bundle (1.5.3): Extracting archive
[production] - Installing symfony/finder (v7.1.6): Extracting archive
[production] - Installing composer/pcre (3.3.1): Extracting archive
[production] - Installing composer/class-map-generator (1.4.0): Extracting archive
[production] - Installing composer/metadata-minifier (1.0.0): Extracting archive
[production] - Installing composer/semver (3.4.3): Extracting archive
[production] - Installing composer/spdx-licenses (1.5.8): Extracting archive
[production] - Installing composer/xdebug-handler (3.0.5): Extracting archive
[production] - Installing symfony/routing (v7.1.6): Extracting archive
[production] - Installing symfony/cache-contracts (v3.5.0): Extracting archive
[production] - Installing symfony/cache (v7.1.7): Extracting archive
[production] - Installing symfony/framework-bundle (v7.1.6): Extracting archive
[production] - Installing symfony/doctrine-bridge (v7.1.6): Extracting archive
[production] - Installing doctrine/sql-formatter (1.5.1): Extracting archive
[production] - Installing doctrine/cache (2.2.0): Extracting archive
[production] - Installing doctrine/doctrine-bundle (2.13.0): Extracting archive
[production] - Installing dama/doctrine-test-bundle (v8.2.0): Extracting archive
[production] - Installing deployer/deployer (v7.5.4): Extracting archive
[production] - Installing doctrine/annotations (2.0.2): Extracting archive
[production] - Installing doctrine/common (3.4.5): Extracting archive
[production] - Installing doctrine/data-fixtures (1.8.0): Extracting archive
[production] - Installing doctrine/doctrine-fixtures-bundle (3.6.1): Extracting archive
[production] - Installing symfony/stopwatch (v7.1.6): Extracting archive
[production] - Installing doctrine/migrations (3.8.2): Extracting archive
[production] - Installing doctrine/doctrine-migrations-bundle (3.3.1): Extracting archive
[production] - Installing webmozart/assert (1.11.0): Extracting archive
[production] - Installing dragonmantank/cron-expression (v3.4.0): Extracting archive
[production] - Installing dunglas/doctrine-json-odm (v1.4.1): Extracting archive
[production] - Installing symfony/validator (v7.1.7): Extracting archive
[production] - Installing symfony/polyfill-uuid (v1.31.0): Extracting archive
[production] - Installing symfony/uid (v7.1.6): Extracting archive
[production] - Installing symfony/polyfill-php81 (v1.31.0): Extracting archive
[production] - Installing twig/twig (v3.14.0): Extracting archive
[production] - Installing symfony/twig-bridge (v7.1.6): Extracting archive
[production] - Installing symfony/twig-bundle (v7.1.6): Extracting archive
[production] - Installing symfony/translation (v7.1.6): Extracting archive
[production] - Installing symfony/password-hasher (v7.1.6): Extracting archive
[production] - Installing symfony/security-core (v7.1.6): Extracting archive
[production] - Installing symfony/security-http (v7.1.7): Extracting archive
[production] - Installing symfony/security-csrf (v7.1.6): Extracting archive
[production] - Installing psr/clock (1.0.0): Extracting archive
[production] - Installing symfony/clock (v7.1.6): Extracting archive
[production] - Installing symfony/security-bundle (v7.1.6): Extracting archive
[production] - Installing symfony/intl (v7.1.7): Extracting archive
[production] - Installing symfony/polyfill-intl-icu (v1.31.0): Extracting archive
[production] - Installing symfony/options-resolver (v7.1.6): Extracting archive
[production] - Installing symfony/form (v7.1.6): Extracting archive
[production] - Installing symfony/asset (v7.1.6): Extracting archive
[production] - Installing easycorp/easyadmin-bundle (v4.14.1): Extracting archive
[production] - Installing symfony/polyfill-php56 (v1.20.0)
[production] - Installing namshi/jose (7.2.3): Extracting archive
[production] - Installing lcobucci/jwt (5.4.1): Extracting archive
[production] - Installing lcobucci/clock (3.3.1): Extracting archive
[production] - Installing lexik/jwt-authentication-bundle (v2.21.0): Extracting archive
[production] - Installing gesdinet/jwt-refresh-token-bundle (v1.3.0): Extracting archive
[production] - Installing giggsey/locale (2.7.0): Extracting archive
[production] - Installing goetas-webservices/xsd-reader (0.4.7): Extracting archive
[production] - Installing guzzlehttp/promises (2.0.4): Extracting archive
[production] - Installing justinrainbow/json-schema (5.3.0): Extracting archive
[production] - Installing symfony/process (v7.1.7): Extracting archive
[production] - Installing knplabs/knp-snappy (v1.5.0): Extracting archive
[production] - Installing knplabs/knp-snappy-bundle (v1.10.2): Extracting archive
[production] - Installing league/mime-type-detection (1.16.0): Extracting archive
[production] - Installing league/flysystem (3.29.1): Extracting archive
[production] - Installing league/flysystem-local (3.29.0): Extracting archive
[production] - Installing league/flysystem-bundle (3.3.5): Extracting archive
[production] - Installing league/flysystem-ftp (3.29.0): Extracting archive
[production] - Installing league/flysystem-memory (3.29.0): Extracting archive
[production] - Installing psr/http-factory (1.1.0): Extracting archive
[production] - Installing league/uri-interfaces (7.4.1): Extracting archive
[production] - Installing masterminds/html5 (2.9.0): Extracting archive
[production] - Installing mikehaertl/php-tmpfile (1.3.0): Extracting archive
[production] - Installing mikehaertl/php-shellcommand (1.7.0): Extracting archive
[production] - Installing mikehaertl/php-pdftk (0.13.1): Extracting archive
[production] - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
[production] - Installing mockery/mockery (1.6.12): Extracting archive
[production] - Installing nelmio/cors-bundle (2.5.0): Extracting archive
[production] - Installing carbonphp/carbon-doctrine-types (3.2.0): Extracting archive
[production] - Installing nesbot/carbon (3.8.1): Extracting archive
[production] - Installing giggsey/libphonenumber-for-php (8.13.49): Extracting archive
[production] - Installing odolbeau/phone-number-bundle (v4.0.1): Extracting archive
[production] - Installing ralouphie/getallheaders (3.0.3): Extracting archive
[production] - Installing guzzlehttp/psr7 (2.7.0): Extracting archive
[production] - Installing psr/http-client (1.0.3): Extracting archive
[production] - Installing guzzlehttp/guzzle (7.9.2): Extracting archive
[production] - Installing php-http/promise (1.3.1): Extracting archive
[production] - Installing php-http/httplug (2.4.1): Extracting archive
[production] - Installing clue/stream-filter (v1.7.0): Extracting archive
[production] - Installing php-http/message (1.16.2): Extracting archive
[production] - Installing php-http/client-common (2.7.2): Extracting archive
[production] - Installing php-http/mock-client (1.6.1): Extracting archive
[production] - Installing php-http/multipart-stream-builder (1.4.2): Extracting archive
[production] - Installing openai-php/client (v0.10.2): Extracting archive
[production] - Installing phaxio/phaxio (2.0.2): Extracting archive
[production] - Installing php-http/stopwatch-plugin (1.4.2): Extracting archive
[production] - Installing php-http/message-factory (1.1.0): Extracting archive
[production] - Installing php-http/logger-plugin (1.4.0): Extracting archive
[production] - Installing php-http/httplug-bundle (1.34.3): Extracting archive
[production] - Installing revolt/event-loop (v1.0.6): Extracting archive
[production] - Installing azjezz/psl (3.0.2): Extracting archive
[production] - Installing veewee/xml (3.3.0): Extracting archive
[production] - Installing php-soap/xml (1.8.0): Extracting archive
[production] - Installing league/uri (7.4.1): Extracting archive
[production] - Installing league/uri-components (7.4.1): Extracting archive
[production] - Installing php-soap/wsdl (1.12.0): Extracting archive
[production] - Installing phpstan/phpdoc-parser (1.33.0): Extracting archive
[production] - Installing phpdocumentor/reflection-common (2.2.0): Extracting archive
[production] - Installing phpdocumentor/type-resolver (1.9.0): Extracting archive
[production] - Installing phpdocumentor/reflection-docblock (5.5.0): Extracting archive
[production] - Installing psr/simple-cache (3.0.0): Extracting archive
[production] - Installing markbaker/matrix (3.0.1): Extracting archive
[production] - Installing markbaker/complex (3.0.2): Extracting archive
[production] - Installing maennchen/zipstream-php (3.1.1): Extracting archive
[production] - Installing phpoffice/phpspreadsheet (2.3.0): Extracting archive
[production] - Installing php-soap/engine (2.13.0): Extracting archive
[production] - Installing php-soap/wsdl-reader (0.18.0): Extracting archive
[production] - Installing php-soap/psr18-transport (1.7.0): Extracting archive
[production] - Installing php-soap/ext-soap-engine (1.7.0): Extracting archive
[production] - Installing laminas/laminas-code (4.15.1): Extracting archive
[production] - Installing phpro/soap-client (3.4.0): Extracting archive
[production] - Installing phpstan/phpstan (1.12.7): Extracting archive
[production] - Installing phpstan/phpstan-doctrine (1.5.5): Extracting archive
[production] - Installing react/promise (v3.2.0): Extracting archive
[production] - Installing rector/rector (1.2.9): Extracting archive
[production] - Installing seld/jsonlint (1.11.0): Extracting archive
[production] - Installing seld/phar-utils (1.2.1): Extracting archive
[production] - Installing seld/signal-handler (2.0.2): Extracting archive
[production] - Installing symfony/psr-http-message-bridge (v7.1.6): Extracting archive
[production] - Installing jean85/pretty-package-versions (2.0.6): Extracting archive
[production] - Installing sentry/sentry (4.10.0): Extracting archive
[production] - Installing sentry/sentry-symfony (5.0.1): Extracting archive
[production] - Installing gedmo/doctrine-extensions (v3.17.1): Extracting archive
[production] - Installing stof/doctrine-extensions-bundle (v1.12.0): Extracting archive
[production] - Installing symfony/polyfill-intl-idn (v1.31.0): Extracting archive
[production] - Installing symfony/mime (v7.1.6): Extracting archive
[production] - Installing egulias/email-validator (4.0.2): Extracting archive
[production] - Installing symfony/mailer (v7.1.6): Extracting archive
[production] - Installing async-aws/ses (1.8.2): Extracting archive
[production] - Installing symfony/amazon-mailer (v7.1.6): Extracting archive
[production] - Installing symfony/debug-bundle (v7.1.6): Extracting archive
[production] - Installing symfony/messenger (v7.1.6): Extracting archive
[production] - Installing symfony/doctrine-messenger (v7.1.6): Extracting archive
[production] - Installing symfony/dotenv (v7.1.6): Extracting archive
[production] - Installing symfony/expression-language (v7.1.6): Extracting archive
[production] - Installing symfony/lock (v7.1.6): Extracting archive
[production] - Installing nikic/php-parser (v5.3.1): Extracting archive
[production] - Installing symfony/maker-bundle (v1.61.0): Extracting archive
[production] - Installing symfony/mercure (v0.6.5): Extracting archive
[production] - Installing symfony/mercure-bundle (v0.3.9): Extracting archive
[production] - Installing monolog/monolog (3.7.0): Extracting archive
[production] - Installing symfony/monolog-bridge (v7.1.6): Extracting archive
[production] - Installing symfony/monolog-bundle (v3.10.0): Extracting archive
[production] - Installing symfony/phpunit-bridge (v7.1.6): Extracting archive
[production] - Installing symfony/rate-limiter (v7.1.7): Extracting archive
[production] - Installing symfony/scheduler (v7.1.6): Extracting archive
[production] - Installing symfony/notifier (v7.1.6): Extracting archive
[production] - Installing symfony/slack-notifier (v7.1.6): Extracting archive
[production] - Installing symfony/stimulus-bundle (v2.21.0): Extracting archive
[production] - Installing symfony/ux-chartjs (v2.21.0): Extracting archive
[production] - Installing symfony/ux-react (v2.21.0): Extracting archive
[production] - Installing symfony/web-profiler-bundle (v7.1.7): Extracting archive
[production] - Installing symfony/webpack-encore-bundle (v2.2.0): Extracting archive
[production] - Installing symfonycasts/micro-mapper (v0.1.4): Extracting archive
[production] - Installing thiagoalessio/tesseract_ocr (2.13.0): Extracting archive
[production] - Installing symfony/css-selector (v7.1.6): Extracting archive
[production] - Installing tijsverkoyen/css-to-inline-styles (v2.2.7): Extracting archive
[production] - Installing twig/cssinliner-extra (v3.13.0): Extracting archive
[production] - Installing twig/extra-bundle (v3.13.0): Extracting archive
[production] - Installing lorenzo/pinky (1.1.0): Extracting archive
[production] - Installing twig/inky-extra (v3.13.0): Extracting archive
[production] - Installing twig/intl-extra (v3.13.0): Extracting archive
[production] - Installing jms/metadata (2.8.0): Extracting archive
[production] - Installing vich/uploader-bundle (v2.4.2): Extracting archive
[production] - Installing wsdltophp/domhandler (2.0.6): Extracting archive
[production] - Installing wsdltophp/wsdlhandler (1.0.5): Extracting archive
[production] - Installing wsdltophp/phpgenerator (4.1.1): Extracting archive
[production] - Installing wsdltophp/packagebase (5.0.4): Extracting archive
[production] - Installing symfony/yaml (v7.1.6): Extracting archive
[production] - Installing composer/composer (2.8.2): Extracting archive
[production] - Installing wsdltophp/packagegenerator (4.1.13): Extracting archive
[production] - Installing zenstruck/callback (v1.5.0): Extracting archive
[production] - Installing zenstruck/assert (v1.5.1): Extracting archive
[production] - Installing symfony/dom-crawler (v7.1.6): Extracting archive
[production] - Installing symfony/browser-kit (v7.1.6): Extracting archive
[production] - Installing behat/mink (v1.12.0): Extracting archive
[production] - Installing zenstruck/browser (v1.9.1): Extracting archive
[production] - Installing fakerphp/faker (v1.23.1): Extracting archive
[production] - Installing zenstruck/foundry (v2.2.2): Extracting archive
[production] - Installing zenstruck/messenger-test (v1.11.0): Extracting archive
[production] Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.
[production] Generating optimized autoload files
[production] composer/package-versions-deprecated: Generating version class...
[production] composer/package-versions-deprecated: ...done generating version class
[production] 160 packages you are using are looking for funding.
[production] Use the `composer fund` command to find out more!
[production] Run composer recipes at any time to see the status of your Symfony recipes.
[production] Executing script cache:clear [KO]
[production] [KO]
[production] Script cache:clear returned with error code 1
[production] !!
[production] !!  In FileLoader.php line 178:
[production] !!
[production] !!    Environment variable not found: "MY_ENV_VAR" in . (which is being import
[production] !!    ed from "/var/www/vhosts/project_dor/deploy/releases/34
[production] !!    6/api/config/routes/easyadmin.yaml"). Make sure there is a loader supportin
[production] !!    g the "easyadmin.routes" type.
[production] !!
[production] !!
[production] !!  In EnvVarProcessor.php line 221:
[production] !!
[production] !!    Environment variable not found: "MY_ENV_VAR".
[production] !!
[production] !!
[production] !!
[production] Script @auto-scripts was called via post-install-cmd
[production] exit code 1 (General error)
@IndraGunawan
Copy link
Contributor

i can't reproduce it

if i do inject the non-exist env-var which is a typo, I get the same error as yours.
make sure there is no typo on the env-var name or can you create a minimal reproducer for it?

@KDederichs
Copy link
Contributor Author

I deployed it twice, with the only difference being the EA route config enabled in one deploy (failed one) and it being disabled in the second one (successful one).

I'll see if I can build a reproducer though

@IndraGunawan
Copy link
Contributor

i tried to remove EA routes config but still have non-exist env-var, there's no error while cache clear but I get 404 while accessing the page where I do inject the service. can you confirm this?

KDederichs added a commit to KDederichs/sf-reproducer that referenced this issue Nov 6, 2024
@KDederichs
Copy link
Contributor Author

https://github.com/KDederichs/sf-reproducer/tree/ea/env

There you go.

run docker compose exec php bin/console cache:clear with it enabled produces the error, with it disabled it doesn't.

While writing this I also found the cause, I do not have that secret set in dev mode (only prod).

The issue here is though that it'll run the cache:clear on composer install in dev mode which will in turn cause this error to happen since it seems to try and instantiate all the routes on cache clear for some reason.

@IndraGunawan
Copy link
Contributor

yes, having the env-var on prod only and composer install on dev will raise the error.

glad that you found the cause

@KDederichs
Copy link
Contributor Author

It shouldn't raise that error though is my point. It didn't before and shouldn't start doing so now

@KDederichs KDederichs changed the title Pretty URL router fails on cache clear when Admins require a service that depend on an ENV that's loaded via secrets Pretty URL Router fails to clear cache if ENV var only exists in PROD Nov 6, 2024
@IndraGunawan
Copy link
Contributor

IndraGunawan commented Nov 6, 2024

the title should be
"Pretty URL Router fails to clear cache in DEV if ENV var only exists in PROD"
because it won't be an issue if you do clear cache on the correct environment

AFAIK. in the previous version. the crud controller is registered to the service container but it has not been initialized because it is not being used anywhere in the cache warmup
since 4.14 EA has its route loader that is being called in cache warmup which iterates all the crud controllers hence it will throw an error if the controller can not be initialized, IMO nothing easyadmin can do here

@KDederichs
Copy link
Contributor Author

AFAIK you can't tell composer to clear the cache after install in prod mode though? At least I've never seen it.
Normal cache clear isn't the issue I could do that with env=prod sure. Issue is when it's triggered by composer after installing the dependencies.

@IndraGunawan
Copy link
Contributor

IndraGunawan commented Nov 6, 2024

you can't tell composer to clear the cache after install in prod mode though?

you can, do check https://symfony.com/doc/current/deployment.html#c-install-update-your-vendors on the orange caution box

@javiereguiluz
Copy link
Collaborator

Note: we don't generate/cache the routes in a cache warmer ... we cache the routes (using this method: https://github.com/EasyCorp/EasyAdminBundle/blob/4.x/src/Router/AdminRouteGenerator.php#L373-L398) after generating them in the custom route loader.

We use cache.system as the cache, but not directly:

->set('cache.easyadmin')
->parent('cache.system')
->tag('cache.pool')

@C0piIot
Copy link

C0piIot commented Nov 27, 2024

I think I'm experiencing a similar issue. With pretty url routes the cache fails to clear in my CI with the message Redis connection failed: php_network_getaddresses: getaddrinfo for redis_host: Temporary failure in name resolution.

In some easyadmin controllers I'm injecting some services that depend on redis for some stats and so. If cache warming needs to instantiate those controllers, it needs to bring up more things that are not available when running phpunit tests, at least in my case.

@nielsverwegen
Copy link
Contributor

nielsverwegen commented Mar 21, 2025

We're encountering the same issue, where some controllers expect Redis or MySql. Now this is initialised by EasyAdmin, while it it isn't available in build steps already. Will this be different in next major release? EasyAdmin 5?

@Naroh091
Copy link

We're experiencing an issue that may be related to this one. We build a Docker image for our project - previously to enabling pretty URLs everything went fine, but now the process fails when executing npm run build with the following message. Looks like FOSJsRoutingBundle is trying to export the EasyAdmin routes, and since in that building step the DB is not available as EasyAdmin expects, if fails:

#17 0.789 Running webpack ...
#17 0.790 
#17 1.589 <s> [webpack.Progress] 0% 
#17 1.589 
#17 1.589 <s> [webpack.Progress] 1% setup before run
#17 1.589 <s> [webpack.Progress] 1% setup before run NodeEnvironmentPlugin
#17 1.589 <s> [webpack.Progress] 1% setup before run RouteDump
#17 5.329 node:internal/errors:984
#17 5.329   const err = new Error(message);
#17 5.329               ^
#17 5.329 
#17 5.329 Error: Command failed: php bin/console fos:js-routing:dump --target=/usr/app/var/cache/fosRoutes.tmp.json --format=json
#17 5.329 
#17 5.329 In FileLoader.php line 182:
#17 5.[329](https://github.com/MalditaEs/DMS/actions/runs/14080605623/job/39432495459#step:7:334)                                                                                
#17 5.329   An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refu  
#17 5.329   sed in . (which is being imported from "/usr/app/config/routes/easyadmin.ya  
#17 5.329   ml"). Make sure there is a loader supporting the "easyadmin.routes" type.    
#17 5.329                                                                                
#17 5.329 
#17 5.329 In ExceptionConverter.php line 101:
#17 5.329                                                                                
#17 5.329   An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refu  
#17 5.329   sed                                                                          
#17 5.329                                                                                
#17 5.329 
#17 5.329 In Exception.php line 24:
#17 5.329                                              
#17 5.329   SQLSTATE[HY000] [2002] Connection refused  
#17 5.329                                              
#17 5.329 
#17 5.329 In Driver.php line 33:
#17 5.329                                              
#17 5.329   SQLSTATE[HY000] [2002] Connection refused

@KDederichs
Copy link
Contributor Author

Same issue I think.
It's just extremely annoying that it does that when you do anything related to composer/cache clearing.

IMO it should do this the first time the production app actually serves a request (which then might take a second longer but if it's cached after no big deal I'd say)

@IndraGunawan IndraGunawan linked a pull request Mar 27, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

6 participants