debug-connection

7nohe's avatarfrom 7nohe

Debug WebSocket connection issues between CLI and FigJam plugin. Use when diagrams aren't syncing or connection fails.

⭐1stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026⬇️1downloads

When & Why to Use This Skill

This Claude skill provides a specialized diagnostic framework for troubleshooting WebSocket communication between CLI environments and FigJam plugins. It enables developers to identify and resolve synchronization failures, port conflicts, and authentication mismatches to ensure seamless real-time diagram updates and canvas rendering.

Use Cases

  • Troubleshooting persistent 'Connecting...' status in FigJam by verifying CLI server availability and port 3456 accessibility.
  • Resolving immediate connection closures caused by secret key mismatches between the CLI serve command and the plugin configuration.
  • Diagnosing 'no-update' issues where the WebSocket is connected but YAML changes fail to reflect on the canvas due to docId mismatches or validation errors.
  • Analyzing message flow (hello, full, patch) to identify whether synchronization bottlenecks occur at the CLI, Plugin UI, or Plugin Main level.
namedebug-connection
descriptionDebug WebSocket connection issues between CLI and FigJam plugin. Use when diagrams aren't syncing, connection fails, plugin shows "Connecting..." indefinitely, or patches aren't being applied to canvas.

WebSocket Connection Debugging

Architecture

CLI serve (Bun) ←── WebSocket ──→ Plugin UI (ui.ts) ←── postMessage ──→ Plugin Main (code.ts)
     │                                  │                                    │
  File watcher                    Browser APIs                          Figma API
  YAML parsing                    WebSocket client                      Canvas rendering

Common Issues

Issue Symptom Solution
CLI not running "Connecting..." indefinitely Start bun run packages/cli/src/index.ts serve diagram.yaml
Port in use Connection refused Check lsof -i :3456, use different port
Secret mismatch Connects then immediately closes Match --secret value in CLI and plugin
YAML errors Connected but no updates Fix validation errors in CLI output
docId mismatch No response after hello Ensure plugin docId matches YAML docId
Patches not applied Connected, canvas unchanged Check Plugin Main console for render errors

Debugging Steps

  1. CLI side: Check terminal for errors, verify YAML with bun run packages/cli/src/index.ts build diagram.yaml
  2. Plugin UI: Right-click plugin → Inspect → Console for WebSocket events
  3. Plugin Main: Figma Desktop → Plugins → Development → Open console

Message Flow

Plugin                          CLI
  │                              │
  │──── hello ─────────────────►│  {type:"hello", docId, secret?}
  │◄──── full ─────────────────│  {type:"full", rev, ir}
  │                              │
  │      [YAML changes]          │
  │◄──── patch ────────────────│  {type:"patch", baseRev, nextRev, ops}
  │                              │
  │      [Reconnect]             │
  │──── requestFull ───────────►│  {type:"requestFull", docId}
  │◄──── full ─────────────────│

JSON Import Errors

  • JSON must be an object with version, docId, nodes
  • DSL format: nodes as array
  • IR format: nodes as object (Record)
  • Validation errors shown in alert with path + message

Quick Test

# Start server
bun run packages/cli/src/index.ts serve examples/diagram.yaml

# Test with wscat
wscat -c ws://localhost:3456
> {"type":"hello","docId":"test"}