ignission / ignission/claude-code-ark
[server] Named Tunnelが劣化しても検知・張り直しをせず、cloudflaredのログも残らない
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 0
- Avg merge
- 1h 31m
- Merged PRs (30d)
- 77
Description
現象
2026-09-18、本番 (tart VM上のArk、--remote のNamed Tunnel) に外からアクセスできなくなった。アプリ本体は正常で、Arkを再起動するまで自然には回復しなかった。
VM内での実測値:
curl localhost:4001/は200、pm2はonline (7時間稼働)curl localhost:20241/readyは{"status":503,"readyConnections":0}cloudflared_tunnel_tunnel_register_fail{error="server_error",rpcName="registerConnection"}が11→13と増え続けていたcloudflared_tunnel_total_requestsが174のまま止まっていた (オリジンに1件も届いていない)cloudflared tunnel infoではedgeが1本しか見えなかった (正常時は4本)- cloudflaredのプロセスは終了せず、生きたまま登録失敗を繰り返していた
公開URLは302を返し続けていた。これはCloudflare Accessの手前の応答なので、オリジンの生死を示さない。
pm2 restart claude-code-ark でcloudflaredが張り直され、readyConnections:4 に戻った。
原因 (Ark側)
- 死活監視がない:
--remoteのNamed Tunnelは、起動時に "Registered tunnel connection" を1回見たら成功扱いにし、以降の接続状態を見ていない。tunnel.on("close")もログを出すだけで再spawnしない (packages/server/src/index.ts:3480)。今回のようにプロセスが終了しない劣化では、closeすら発生しない - cloudflaredのログを捨てている: stdout/stderrは接続成功の文字列検出にだけ使い (
packages/server/src/lib/tunnel.ts:191)、pm2のログに出していない。今回も登録に失敗した理由を追えなかった
提案
- cloudflaredのmetricsエンドポイント (
/ready) を定期的に確認し、503が一定時間続いたらcloudflaredを張り直す- metricsのポートは既定だと空きポートを自動で選ぶ (今回は20241)。Arkから確実に叩くには
--metrics 127.0.0.1:<port>で固定して渡す
- metricsのポートは既定だと空きポートを自動で選ぶ (今回は20241)。Arkから確実に叩くには
- cloudflaredのstdout/stderrを行単位で
[cloudflared]プレフィックス付きでpm2のログへ流す - 張り直しが起きたことをログに残す
受け入れ条件
- cloudflaredの接続0本が続くと、Arkを再起動しなくても自動で張り直される
- cloudflaredの出力を
pm2 logs claude-code-arkで読める - Quick Tunnelの挙動を壊さない
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/server/src/index.ts around line 3480 to trace Named Tunnel lifecycle and the existing close handling, then read packages/server/src/lib/tunnel.ts around line 191 for cloudflared process output handling. Check how --remote and Quick Tunnel paths are distinguished before planning metrics polling and log forwarding. Done means degraded connections trigger recovery, cloudflared output reaches pm2 logs, recovery is logged, and Quick Tunnel behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cloud, devops, infrastructure, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100