Skip to content
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

Cache connection required during package discovery process #620

Closed
Catzilla opened this issue Apr 25, 2019 · 13 comments
Closed

Cache connection required during package discovery process #620

Catzilla opened this issue Apr 25, 2019 · 13 comments

Comments

@Catzilla
Copy link

Catzilla commented Apr 25, 2019

  • Telescope Version: 2.0.4
  • Laravel Version: 5.8.14
  • PHP Version: 7.3.4
  • Database Driver & Version: MariaDB 10.3.14

Description:

I'm using Redis as cache driver for my application.
Also I'm using Docker and CI/CD solution for build and deploy.
As part of my build pipeline I run composer install, but because Redis not available during build stage, I receiving following error:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

In AbstractConnection.php line 155:
                                                                               
  php_network_getaddresses: getaddrinfo failed: Name or service not known [tcp://redis:6379]

After that my pipeline fails.

It seems that the problem occurs here:

if (! $this->cache->get('telescope:dump-watcher')) {

I turned off DumpWatcher in the config, and the problem has disappeared.

Steps To Reproduce:

  1. Create fresh Laravel application with Telescope installed
  2. Run composer require predis/predis
  3. Set CACHE_DRIVER env variable to redis
  4. Set REDIS_HOST env variable to any unavailable host
  5. Run composer install
@danilopolani
Copy link
Contributor

You could try to add telescope to dont-discover config in composer.json to disable it from package discovery, of course you'd need to register it manually. Take a look to the section Opting Out Of Package Discovery here: https://laravel.com/docs/5.8/packages#package-discovery

@Catzilla
Copy link
Author

@danilopolani, Unfortunately, this does not solve the issue. This is the first thing I tried when I ran into this problem. During package discovery process, the console kernel is loaded, and every manually registered service provider is called, which leads to the same result as if we did not exclude the package from discovery.

@taitai42
Copy link

We had the same problem, on our end we fixed it by running our build with a TELESCOPE_ENABLED=false env var.

@taylorotwell
Copy link
Member

@themsaid do you know why this is needed?

@deleugpn
Copy link
Contributor

deleugpn commented May 2, 2019

Disabling telescope for builds seems a reasonable solution.

@themsaid
Copy link
Member

themsaid commented May 2, 2019

@taylorotwell While TelescopeServiceProvider is being booted we run Telescope::start() which registers the watchers, while the DumpWatcher is being registered we check if the Dumps screen is open in the browser so we decide whether or not we should collect dumps. That's when Telescope tries to use your cache driver, and if it's not available you get an error.

I agree that it makes sense to disable Telescope in this case.

@danvim
Copy link

danvim commented Jan 25, 2020

@taylorotwell Sorry to ask, why is this issue closed? I'm still experiencing this problem. Is there no official way of fixing this?

I wanted Telescope to work in my local development environment in Docker Compose. My current mitigation method is to add --no-scripts to composer install during my Docker build, and instead, run composer dumpautoload when the container starts.

In my case, I'm not just using Docker for CI/CD, but for my actual dev environment. So it doesn't make sense to disable Telescope in my case.

I just found this issue, but I've made a StackOverflow issue a while ago: https://stackoverflow.com/questions/59810019/dockerfile-build-laravel-trying-to-connect-to-redis-service-yet-to-up

@djtarazona
Copy link

I'm having this issue as well. @themsaid, can Telescope automatically be disabled in this case (package discovery)?

@kopotp
Copy link

kopotp commented May 3, 2020

Latest laravel 7.0 and Telescope 3.3 - still got this error in Docker/Kubernetes context, i am applying TELESCOPE_ENABLED=false in Dockerfile ENV to get composer dump autoload working, then TELESCOPE_ENABLED=true in Kubernetes ENV, and also i have to move all caching like php artisan config:cache (btw Telescope doesn't work without this command) to Kubernetes after container has started, which is not good.

@mnavarrocarter
Copy link

I was experiencing the same issue and I fixed it by removing the package discovery command completely from the post-autoload-dump hook in my composer.json. The only benefit of package discovery is just automatically copying default config files, assets, registering facades and providers. I can do that manually and have peace of mind.

@m1stermanager
Copy link

m1stermanager commented Oct 12, 2020

i haven't changed much about my environment lately except for bumping to laravel 8.X.... and telescope to 4.x per the upgrade guide. Running into this right now...... was something fixed in 7.x and reverted in 8.x? (or broken in 4.x)

@m1stermanager
Copy link

I figured this out. the change to prepend the scheme (which defaults to tcp) broke me: laravel/framework@aa4e269#diff-89b6287633db08fda2f83951857e18fd

I was including the scheme (tls for us) in the REDIS_HOST, causing it to build tcp://tls://

@alecpl
Copy link

alecpl commented Jan 17, 2023

I'm NOT using Telescope and I have the same problem.

taylorotwell pushed a commit that referenced this issue Jan 30, 2023
* Handle redis connection exception on DumpWatcher register

Fixes issue #620

* Cleanup after previous solution removed

* Include another case and refactor

* Add missing !

* Update src/Telescope.php

* Update src/Watchers/DumpWatcher.php

* use Exception

---------

Co-authored-by: Dries Vints <dries@vints.io>
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

No branches or pull requests