Redis
errorcore instruments the ioredis client library when IO recording is active. Commands are recorded with their name, key target, and duration.
Setup
Initialize errorcore before creating your Redis client:
import errorcore from "errorcore";
errorcore.init({
service: "session-api",
transport: { type: "file", path: "./errors.ndjson" },
allowUnencrypted: true,
});
// create the client after init()
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL);What gets recorded
Each command in the IO timeline includes:
- command name (
GET,SET,HGET,LPUSH,DEL, etc.) - key or key pattern
- duration in milliseconds
- position in the ordered timeline
2ms GET session:abc123
4ms HGET user:789 preferences
9ms SET session:abc123 (expired)
11ms Error thrown: session not foundValues
Full values are not captured. Redis values can be large (serialized objects, cached responses, queue payloads) and rarely help explain why an error occurred. The command name and key are usually sufficient to understand the operation sequence.
Pipelines and transactions
Commands inside pipelines and MULTI/EXEC blocks are recorded individually. Each command appears as its own entry in the timeline with its own duration, so you can see whether a specific command within a transaction was the slow one.
Common patterns
Redis capture is most useful for:
- Cache misses: when a missing key triggers a fallback path that fails
- Queue operations: when
BRPOPorLPUSHraces with other consumers - Distributed locks: when
SET NXcoordination does not behave as expected - Rate limiting: when counter keys expire or do not exist when checked
The timeline shows the order of commands relative to the error, which is often enough to identify the race condition or missing key.