Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Page hangs indefinitely when the phpredis extension is loaded but no Redis server is reachable (`preloadDirectoryFiles`)

オープン
#1,008 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
laravel, php, redis
領域
backend

調査の方向性

Start in preloadDirectoryFiles() in app/Functions/functions.php, which is reached from findAvatar()/findFile() during resources/views/linkstack/modules/meta.blade.php rendering, and check how it chooses Redis via class_exists('Redis'). Redis connection settings live in config/database.php. Reproduce by loading a public profile with the redis extension present and REDIS_HOST pointing at an unreachable address. Done when the page renders promptly without Redis, and the maintainers have agreed on which of the three suggested approaches to take.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

On shared hosting where the redis PHP extension is installed but no Redis server is available (e.g. OVH shared hosting), the public profile page never loads. The request hangs until the web server kills it (FastCGI idle timeout, 160 s on OVH), and nothing is written to storage/logs/laravel.log.

The hang happens while rendering resources/views/linkstack/modules/meta.blade.php. That view calls findAvatar() / findFile(), which call preloadDirectoryFiles() in app/Functions/functions.php. Because class_exists('Redis') is true, preloadDirectoryFiles() calls Redis::get() / Redis::setex(), which connect to the default REDIS_HOST=127.0.0.1:6379.

On this host, connections to 127.0.0.1:6379 are not refused. They are silently dropped, so each connection attempt blocks until default_socket_timeout (60 s). Several calls in a single page render add up to more than the server timeout. The surrounding try/catch doesn't help because nothing is thrown before the request is killed, and set_time_limit() doesn't apply either, since time spent waiting on a socket isn't counted.

To Reproduce

  1. Install LinkStack on a host where the redis PHP extension is loaded but no Redis server listens on 127.0.0.1:6379 (and connections are dropped rather than refused).
  2. Keep the default .env values (REDIS_HOST=127.0.0.1, REDIS_PORT=6379, CACHE_DRIVER=file).
  3. Open the home page / a public profile page.
  4. The request hangs until the web server timeout.

Evidence

Trace of the request (logging autoloads, Laravel events and SQL as they happen). The last event before the hang is the meta module:

0.103s  SQL 1.1ms select "links".*, "buttons"."name" from "links" inner join "buttons" ...
0.103s  event creating: linkstack.linkstack
0.104s  event composing: linkstack.linkstack
0.104s  event creating: linkstack.modules.meta
0.104s  event composing: linkstack.modules.meta
        <nothing more until the request is killed>

Standalone check on the same host:

extension redis loaded : YES
class Redis            : YES
default_socket_timeout : 60s
connect 127.0.0.1:6379 : 5.00s  failed (110 Connection timed out)

Web server log:

AH10141: FastCGI: comm with server ".../index.php" aborted: idle timeout (160 sec)
AH10149: FastCGI: incomplete headers (0 bytes) received from server ".../index.php"

Workaround

Point REDIS_HOST to a non-existent unix socket in .env so the connection fails immediately instead of timing out:

REDIS_HOST=/tmp/no-redis.sock

The exception is then caught, and the page loads normally.

Suggested fix

  • Use Redis in preloadDirectoryFiles() only when it is explicitly enabled (e.g. CACHE_DRIVER=redis or a dedicated .env option), not just whenever the Redis class exists, and/or
  • set a short connect/read timeout on the Redis connection (e.g. timeout / read_timeout in config/database.php), and/or
  • after the first failure, stop trying Redis for the rest of the request (memoize the failure in a static variable).

Environment

  • LinkStack version: 4.8.6
  • PHP: 8.5.7 (same behaviour on 8.3)
  • Database: SQLite
  • Hosting: OVH shared hosting (Apache + FastCGI), redis extension loaded, no Redis server
主要言語
PHP
スター
3.9k
フォーク
440
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

LinkStackOrg/LinkStack のほかの issue

LinkStackOrg/LinkStack の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。