fix: update() not atomic, create() set+sadd not transactional, list() N+1 Redis calls #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code review findings — must fix before production use:
1. update() bypasses WATCH (not atomic)
Plain read-then-write. Concurrent updates silently overwrite each other.
Fix: route through mutateTaskAtomically or add WATCH/MULTI/EXEC.
Also bypasses state machine validation — dangerous as a public method.
2. create() set+sadd not in same transaction
If process crashes between SET NX and SADD, task exists in Redis but is invisible to list().
Fix: wrap both in MULTI/EXEC pipeline.
3. list() is O(n) round-trips
Promise.all(taskIds.map(id => this.get(id))) — 100 tasks = 100 GET commands.
Fix: use client.mget() or a pipeline to fetch all task keys in one round-trip.