Page hangs indefinitely when the phpredis extension is loaded but no Redis server is reachable (`preloadDirectoryFiles`)
還沒有人認領這個 Issue。
評估
研究方向
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
- Install LinkStack on a host where the
redisPHP extension is loaded but no Redis server listens on127.0.0.1:6379(and connections are dropped rather than refused). - Keep the default
.envvalues (REDIS_HOST=127.0.0.1,REDIS_PORT=6379,CACHE_DRIVER=file). - Open the home page / a public profile page.
- 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=redisor a dedicated.envoption), not just whenever theRedisclass exists, and/or - set a short connect/read timeout on the Redis connection (e.g.
timeout/read_timeoutinconfig/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),
redisextension loaded, no Redis server
- 主要語言
- PHP
- 星號
- 3.9k
- 分支
- 440
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
LinkStackOrg/LinkStack 的其他 Issue
-
難度 5/5 一週以上 新手友好度 20/100
LinkStackOrg/LinkStack#1011 ·
-
難度 3/5 1-2 天 新手友好度 62/100
LinkStackOrg/LinkStack#1007 ·
-
難度 4/5 3-5 天 新手友好度 44/100
LinkStackOrg/LinkStack#1003 · 1 則留言 ·
-
難度 3/5 1-2 天 新手友好度 56/100
LinkStackOrg/LinkStack#1002 ·
-
contributor-friendly dependencies enhancement good first issue help wanted javascript needs more work valid
難度 2/5 1-3 小時 新手友好度 55/100
LinkStackOrg/LinkStack#995 · 1 則留言 ·
查看 LinkStackOrg/LinkStack 的全部 Issue
相似的 Issue
-
0.kind: enhancement 9.needs: package (update)
難度 2/5 1-3 小時 新手友好度 67/100
NixOS/nixpkgs#577156 · 3 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
tine-groupware/tine#277 ·
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
MagnaCapax/PMSS#1142 · 1 則留言 ·
維護者通常 3 天內回覆
-
Native-arrow select renders a second Jetpack chevron可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
Automattic/static-site-importer#2294 ·
維護者通常 1 天內回覆
-
bug 🐛
難度 2/5 1-3 小時 新手友好度 72/100
netalertx/NetAlertX#1856 · 1 個 reaction ·
維護者通常 1 天內回覆