Debugging Local Replay

作者 PostHog469d1773e9cb无许可证收录于 2026年10月8日更新于 2026年10月8日

Debugs why session recordings aren't appearing in the local dev environment. Use when a developer reports that local replay ingestion isn't working, recordings aren't showing up despite /s calls, or the replay pipeline seems broken after hogli start. Covers the full local pipeline: SDK capture, Caddy proxy, capture-replay (Rust), Kafka, ingestion-sessionreplay (Node), recording-api (Node), SeaweedFS, and common failure modes like orphaned processes, stuck phrocs workers, and trigger misconfiguration.

AI 生成的概览

指导开发者排查本地会话回放链路,从浏览器 SDK 采集到存储与播放。

功能
提供分层排查本地会话回放的流程,依次检查 SDK 采集、Caddy 代理、capture-replay、Kafka、ingestion-sessionreplay、recording-api 与 SeaweedFS。它把缺少 /s 请求、播放卡住等症状对应到可能原因,列出需要确认的进程、端口与 Docker 容器,并给出检查命令。它还指向一份常见故障参考文件,例如残留进程与卡住的 worker。
适用场景
当开发者反馈本地回放采集不工作、有 /s 请求但看不到录制,或启动本地环境后回放链路似乎损坏时使用。
运行要求
无脚本,仅为说明文档。需要本地开发环境及回放链路组件(Caddy、capture-replay、Kafka、ingestion-sessionreplay、recording-api、SeaweedFS)、Docker 容器,以及 lsof、docker、kcat、curl 等命令行工具。

Debugging local session replay

When a developer says "local replay isn't working" or "recordings aren't showing up", work through these layers in order. The local replay pipeline has several moving parts and failures are usually silent.

Quick symptom guide

SymptomLikely cause
No /s calls in Network tabSDK not recording — triggers, settings, or recorder script issue (Step 1)
/s calls return 200 but no recordings in listIngestion pipeline broken — capture-replay, Kafka, or ingestion-sessionreplay (Steps 2-3)
Recordings listed but playback stuck on "Buffering..."recording-api (port 6741) not running (Step 2)
Recorder script MIME type or CORS error in consoleFrontend build stale — need pnpm build + pnpm copy-scripts (Step 1)

The local replay pipeline

text
Browser SDK  →  /s endpoint (Caddy proxy :8000)             →  capture-replay (Rust, :3306)             →  Kafka (session_recording_snapshot_item_events topic)             →  ingestion-sessionreplay (Node, :6740, PLUGIN_SERVER_MODE=recordings-blob-ingestion-v2)             →  SeaweedFS (blob storage, :8333)             →  recording-api (Node, :6741, PLUGIN_SERVER_MODE=recording-api)             →  Frontend

A break at any point in this chain means no recordings in the UI. The diagnostic approach is to find where the chain breaks.

Step 1 — Is the SDK even trying to record?

Ask the developer to open browser DevTools Network tab and filter for /s.

If no /s calls at all: The SDK isn't attempting to send recording data. Investigate client-side causes:

  • Triggers configured in project settings. If URL triggers, event triggers, or linked flag triggers are set up, recording won't start until a trigger fires. This is the most common cause for developers who've been testing trigger features. Check Session replay settings in the local UI (Project settings > Session replay). Remove or adjust triggers to allow recording to start.
  • Recording disabled in project settings. Session replay may be toggled off.
  • Sample rate set too low. If $replay_sample_rate is < 1.0, sessions may be sampled out.
  • SDK not initialized with recording. Check the local app's PostHog initialization — session_recording must not be explicitly disabled.
  • Wrong PostHog host. The local app must point to http://localhost:8000 (or wherever the local Caddy proxy is running).
  • Ad blocker. Even in local dev, browser extensions can block the recorder script or /s endpoint.
  • Recorder script failed to load (MIME type / CORS error). The browser console may show MIME type ('text/html') is not executable for posthog-recorder.js or a CORS error for lazy-recorder.js. This means Django is serving an HTML page (usually the login redirect) instead of the JS file — the static recorder scripts are stale or missing. See recorder script build failure.

If /s calls are happening with 200 responses: The SDK is recording and capture is receiving data. The break is downstream — proceed to Step 2.

If /s calls are returning errors (4xx/5xx): The capture service may be down or misconfigured. Check capture-replay in phrocs.

Step 2 — Are the required processes running?

Check that these phrocs processes are running and healthy. A "running" process that never produced output after tsx watch src/index.ts is effectively dead.

Key processes and their ports

ProcessPortWhat it does
capture-replay3306Rust service receiving /s, writes to Kafka
ingestion-sessionreplay6740Node consumer processing recordings from Kafka
recording-api6741Node service serving replay data to the frontend

Verify with:

bash
lsof -nP -i :3306 -i :6740 -i :6741

If ports are not listening: The processes haven't started or are stuck. See common failures.

If ports are listening: The pipeline processes are running. Proceed to Step 3.

Docker dependencies

These Docker containers must be running and healthy:

ContainerPurpose
posthog-kafka-1Message bus for recording events
posthog-db-1Postgres for metadata
posthog-redis7-1Redis for state
posthog-clickhouse-1ClickHouse for session data
seaweedfs-mainBlob storage for recording data

Check with:

bash
docker ps --format "table {{.Names}}\t{{.Status}}" | grep -E "kafka|db|redis7|clickhouse|seaweed"

All should show (healthy) except seaweedfs which doesn't have a health check. If seaweedfs-main is missing, the replay Docker profile may not be active — check the docker-compose phrocs process output for --profile replay.

Step 3 — Is data flowing through Kafka?

If capture-replay is running and receiving /s calls, data should land on the session_recording_snapshot_item_events Kafka topic. Check the Kafka UI at http://localhost:8080 (if the debug_tools intent is enabled) or use kcat:

bash
kcat -b localhost:9092 -t session_recording_snapshot_item_events -C -c 5 -e

If the topic is empty or doesn't exist: capture-replay isn't writing to Kafka. Check its phrocs logs for Kafka connection errors.

If data is on the topic but recordings don't appear: ingestion-sessionreplay isn't consuming. Check if it's stuck, crashed, or if an orphaned process is holding the consumer group (see common failures).

Step 4 — Check SeaweedFS

Ingestion writes recording blobs to SeaweedFS. Verify it's accessible:

bash
curl -s http://localhost:8333/ | head -5

The SESSION_RECORDING_V2_S3_ENDPOINT env var must be set correctly. In bin/start, this defaults to http://seaweedfs:8333 (the Docker hostname). Host processes resolve this via Docker networking.

Common failures reference

See common failures for detailed diagnosis of:

  • Orphaned Node processes holding Kafka consumer groups
  • Processes stuck at bin/wait-for-docker
  • tsx watch silently swallowing crashes
  • Port conflicts between Docker and host processes
  • Cargo build lock contention on startup

来源与署名

来源:PostHog/ai-plugin位于skills/debugging-local-replay提交469d177

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架

更多来自 PostHog/ai-plugin 的技能

Writing Simplified Technical English

PostHog

应用 ASD-STE100 简化技术英语规则,让智能体撰写的文字含义明确、便于执行。

Writing & Content2026年10月8日

Working With Task Comments

PostHog

通过 PostHog MCP exec 调度器读取并解读 PostHog 任务、产物和画布上的评论。

Productivity & Workflow2026年10月8日

Working With Skills

PostHog

指导智能体使用 PostHog 的 skill-* MCP 工具来发现、读取、创建、更新和重构技能。

AI & Agents2026年10月8日

Working With Scouts

PostHog

关于如何把监控任务委派给 PostHog Signals 侦察代理、处理其报告并长期调校整个代理集群的操作手册。

AI & Agents2026年10月8日

Validating And Publishing Canvases

PostHog

Validate and publish a canvas source project safely: the source-project shape, declared capabilities, reading the current version pointer, iterating on validation diagnostics, guarded publishing with expected_current_version_id, staging a draft build and promoting it, waiting out the queued build, and recovering from a 409 version_conflict or a 429 capacity limit without overwriting concurrent work. Use whenever a canvas edit is ready to save, a draft build is wanted, a canvas publish or build returns diagnostics or a conflict, or a task needs to understand canvas version history.

待分类2026年10月8日

Understanding Billing Usage

PostHog

Explains PostHog billing usage and spend from the customer's visible Billing MCP tools. Use when the user asks why usage or spend is high, which product or project is driving usage, what a usage type means, how to reduce usage, what changed over time, why they got a usage change alert, or whether a spike/drop alert was real or noisy. Also use before product-specific analytics skills when the user names a billable PostHog product metric such as events, recordings, feature flag requests, exceptions, survey responses, synced rows, logs, AI events, AI credits, or Inbox credits. Starts from Billing usage/spend tools, then routes to customer-visible product MCP surfaces for deeper investigation.

待分类2026年10月8日