[superlog] Downgrade transient Redis errors in insights worker to WARN#482
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
The latest updates on your projects. Learn more about Unkey Deploy
|
| function isTransientRedisError(error: Error): boolean { | ||
| return TRANSIENT_REDIS_ERROR_PATTERNS.some((pattern) => | ||
| pattern.test(error.message) | ||
| ); | ||
| } |
There was a problem hiding this comment.
isTransientRedisError is unexported and untested
The patterns in TRANSIENT_REDIS_ERROR_PATTERNS are the sole gate between WARN and ERROR alerting. There is no worker.test.ts, and the function is unexported, so there is currently no way to verify that the regexes correctly match the intended Redis messages (e.g. READONLY Writes are temporarily rejected…) and do not accidentally match unrelated errors. If a pattern is wrong or a Redis error message format changes, operators would silently receive WARN for a real incident with no indication anything is wrong. Exporting isTransientRedisError (or the pattern list) and adding a few unit tests would make the boundary explicit and regression-proof.
|
Reviewed with a subagent pass. This looks useful and safe in principle: it only downgrades known transient Redis worker error events to WARN while keeping unexpected worker errors at ERROR, and its original checks are green. I am not merging it because this PR targets main, while repo policy and this merge pass require staging. Please retarget/recreate this against staging and rerun checks; it should be a good candidate after that. Minor non-blocking follow-up: a small test around transient-vs-unexpected Redis worker errors would keep the matcher from drifting. |
izadoesdev
left a comment
There was a problem hiding this comment.
Approved after refreshing onto staging and adding focused coverage for the transient Redis error classifier.
Local verification:
cd apps/insights && bun test src/worker-errors.test.tscd apps/insights && bun run check-typesbun run lintbun run test
The change keeps expected Redis failover/connection-close worker errors at WARN while preserving ERROR for unknown worker failures.
Summary
During a Redis server upgrade the insights worker emitted two
worker.errorERROR logs (READONLY Writes are temporarily rejected due to server upgradeandERR caller gone), creating a false-positive incident. The BullMQ worker is configured withmaxRetriesPerRequest: nullso ioredis reconnects automatically; all jobs continued to succeed after both errors.The root cause is that
worker.on("error")unconditionally logs every Worker-level connection error at ERROR severity, even for well-known transient Redis signals that require no operator action.This patch adds a
TRANSIENT_REDIS_ERROR_PATTERNSlist (READONLY,ERR caller gone,ECONNRESET,Connection is closed,Socket closed unexpectedly) and routes matched errors to WARN level. Unexpected Worker errors continue to be logged at ERROR. An alternative approach would be to suppress transient errors entirely (no log at all), but WARN preserves visibility for debugging without triggering incidents.Incident on Superlog
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Downgraded transient Redis errors in the insights worker from ERROR to WARN to avoid false-positive incidents during upgrades/failovers. Unexpected errors still log at ERROR; job processing is unchanged.
worker.on("error")to route WARN vs ERROR inemitInsightsEvent.bullmqusesmaxRetriesPerRequest: null, soioredisreconnects and jobs keep succeeding.Written for commit 5993422. Summary will update on new commits.