Serverless Debugging
Systematic debugging when traditional server logs and SSH are unavailable. Complements test-failure-triage with environment-specific constraints.
When to use
- Intermittent 5xx from functions
- Timeout or memory limit errors
- Works locally but fails when deployed
When not to use
- Long-running container services with full shell access
- Client-only bugs (use browser DevTools skills)
Workflow
- Reproduce — identify trigger (HTTP event, queue, schedule)
- Logs — cloud provider log group/stream; filter by request ID
- Config — compare env vars/secrets: local vs deployed (names only, never log values)
- Limits — timeout, memory, payload size, concurrency
- Cold start — init duration, heavy imports, VPC ENI delay
- Dependencies — outbound network, IAM permissions, region mismatch
- Minimal fix — smallest change; redeploy; verify with structured log line
Common failure modes
| Symptom | Likely cause |
|---|---|
| Task timed out | Slow downstream, missing async, too much work in handler |
| Cannot find module | Bundle/packaging; wrong runtime |
| Access denied | IAM role, resource policy |
| Connection timeout | VPC/subnet/NAT; wrong security group |
| Works once then fails | State in /tmp; connection pool reuse |
Practices
- Structured JSON logs with
requestId,stage,durationMs - Fail fast on missing required env with clear error message (no secret values)
- Use X-Ray or vendor tracing for cross-service calls
- Keep handlers thin; push heavy work to async queues when needed