Skip to content

service-cache: the shared cache's derived Redis connection has no error listener, so a Redis outage prints "[ioredis] Unhandled error event" with a stack per reconnect attempt (#31596 follow-up) #31723

Closed

Description

@objectstack-fleet

domain:server#1 · os-steve · session_01ADHkmPF1skfu2kx89BEXZi

Filing gate: ① product defect with a named seam and a measured reach (out-of-scope finding of #31596's os-dev-report 6728820009). ⛔ Not a claim.
reach: on PR #31721's head, the redis black-hole test needed its own no-op error listener on the cache's duplicate() connection. Without one, every reconnect attempt during an outage logs [ioredis] Unhandled error event with a stack. The seam is packages/services/service-cache/src/cache-service-plugin.ts:136 on 35a9c694 (base.duplicate()).
Business reason: #31596 asks for every Redis client to log an outage once, with no credential in the line. PR #31721 does this for the cluster driver's command and subscriber connections, which feed one ClusterDriverLiveness. The shared cache derives a third connection, and that one still floods the log on every replica during an outage. The flood buries the one warning operators need, and ioredis' default line may carry connection details.
Reader: the next domain:server seat, from pm:queue, after PR #31721 merges (it uses #31721's watchRedisConnection and the driver's liveness).
Dedupe (open AND closed): cache duplicate error listener redis → #31596 only (the parent).
class: a · type: Bug
Grade: p2. Log noise during an outage; nothing crashes and no cached value is wrong.

维护者速读

Redis 断线时,共享缓存另开的那条 Redis 连接没有挂错误监听,每次重连都打印一大段报错,把真正有用的那一条告警淹没了。挂上监听,并接到集群驱动的同一个连接状态里,让断线只记一次。

What to build

  1. The cache's derived connection attaches an error listener and reports to the cluster driver's liveness (watchRedisConnection(derived, liveness, 'cache') from @objectstack/service-cluster-redis, with the liveness read the way readClusterDriverHealth reads it). Then one outage still logs once across all three connections, and cluster.resync fires only when all three are back. If the liveness cannot be reached from the cache plugin, attach a listener that logs once per outage with describeConnectionError. ⛔ Never a silent swallow.
  2. Detach before the cache's own quit(), so a deliberate close is not reported as an outage.
  3. Tests: with the derived connection's server stopped, no Unhandled error event, and one warning. CONTROL: the memory driver and an in-process cache are unchanged.

Surface

  • Expected file surface: packages/services/service-cache/src/cache-service-plugin.ts, tests, root .changeset/.
  • Clause-②: no.

Parent: #31596. Epic: #3814.

Activity

  1. added
    bug
    priority:p2
    pm:queue
    domain:server
    on Nov 8, 2026
  2. objectstack-fleet commented on Nov 8, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: none

    Triage: confirmed · domain:server · p2 · pm:queue · 2026-11-08T23:54Z

    ⛔ Not a claim.


    Generated by Claude Code

  3. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 9, 2026
  4. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

    Claim: PM loop round 9 · 2026-11-09T03:17Z
    Session: session_01ADHkmSTGuRMEEW3vjJtdVG (card thread, dev) · seat session_01ADHkmQKZzp4DLtqiCkZZRM
    Account: os-steve
    Branch: claude/project-thread-v828m0
    Worktree: objectstack-issue-31723
    Domain: domain:server
    Seat: domain:server#2
    File surface: packages/services/service-cache/src/cache-service-plugin.ts, tests, root .changeset/. ⛔ No packages/spec/**, ui/**, no edits to service-cluster-redis
    Container & model: S, mode:thread, model: default tier, effort: medium
    Clause-②: no
    Metadata-protocol: none
    Responsibility: follow-up of #31596 (PR #31721, merged); epic #3814 multi-replica
    Thread-read: none
    Premise: holds as filed, read at claim on origin/main c2bb879f: cache-service-plugin.ts line 136 derives base.duplicate() with no error listener
    Serial constraints cleared: PR #31721 merged (watchRedisConnection and ClusterDriverLiveness on main); seat 1 released the card to this seat (different file from #31597 / #31722)

    Scope: Fixes #31723. The cache's derived Redis connection reports to the cluster driver's one liveness through watchRedisConnection, stays quiet when no liveness exists, and detaches before a deliberate close. Order: /mnt/project-files/server-seat2/standard-order.md + /mnt/project-files/server-seat2/31723-delta.md. Summons: the maintainer's 「server 任务很多,你应该跟进并发5」 (project chat, 2026-11-09T02:28Z).

  5. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

    Claim amendment · #31723 · 2026-11-09T03:18Z

    The dev stopped at the delta's ruling 1 before writing code (needs_decision). Measured on origin/main c2bb879f: the cluster driver's liveness has no public read (readLiveness in service-cluster's cluster-resync.ts is module-private), and watchRedisConnection lives in service-cluster-redis, a devDependency of service-cache. Making that a runtime dependency would pull ioredis into every consumer of service-cache.

    Seat ruling (A): one connection watcher, hoisted into service-cluster, which service-cache already depends on at runtime.

    • New export watchClusterDriverConnection(cluster, client, source): () => void resolves the liveness internally, takes a structurally typed client (on / off / status), and returns a no-op disposer when no liveness is offered.
    • service-cluster-redis's watchRedisConnection delegates to it, with its signature and behavior unchanged.
    • service-cache calls it on the derived connection.
    • No new dependency, no Symbol reach-around.

    Amended lines:

    • File surface: packages/services/service-cache/src/cache-service-plugin.ts, packages/services/service-cluster/src/** (the new function, its export, tests), packages/services/service-cluster-redis/src/client.ts (delegation only), tests, root .changeset/. ⛔ No packages/spec/**, ui/**, no new package dependency.
    • Clause-②: yes (widening). This is a new public name, accepted by the seat.
  6. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmSTGuRMEEW3vjJtdVG
    os-dev-report

    {
      "issue": 31723,
      "status": "done",
      "branch": "claude/project-thread-v828m0",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/31787",
      "session": "session_01ADHkmSTGuRMEEW3vjJtdVG",
      "premise_still_valid": true,
      "summary": "Seat ruling A, implemented. service-cluster gains ClusterDriverLiveness.watchConnection, the one listener style, and the export watchClusterDriverConnection(cluster, client, source), which is a no-op without a liveness. service-cluster-redis watchRedisConnection delegates to it, with an unchanged signature and tests untouched. service-cache watches only the connection it derives, as 'cache'. One outage logs once, and cluster.resync waits for the cache connection. With no liveness offered, the connection gets its own liveness on the plugin logger, so it logs once and is never silent. The plugin detaches before the deliberate quit on kernel:shutdown.",
      "tests": "Head c9c845d2. RED on main (4 prod files restored from c2bb879f, rebuilt): topology file 4 failed | 21 passed; tests 1-2 saw 3x '[ioredis] Unhandled error event:'. GREEN 25/25. Under the lock, build+typecheck+test VERDICT 0: service-cluster 145/145, service-cluster-redis 41/41 (real-redis outage test included), service-cache 79/79. Ablations via ablation-replace, each restored blob==HEAD (src-imported subjects, no dist leg): A1 no watch -> 4 failed; A2 detach after quit -> 1 failed (shutdown pin); A3 fallback removed -> 1 failed (no-liveness pin); B1 watchClusterDriverConnection no-op -> 1 failed (service-cluster pin).",
      "gates": "dispatch-gates --commands: 66 derived, all 66 exit 0 on c9c845d2. Three read exit 3 first on prerequisites and re-ran exit 0: the teardown self-test after fetching fixture 621a4876, and dual-build-cjs-loads plus lean-entry-closure after turbo build --filter='./packages/**' (81/81). --ran: 66 run, 0 NOT-MEASURED, 0 UNRUN. eslint --no-inline-config on the 3 src dirs exit 0. CI check-runs on #31787: in_progress at report time.",
      "dogfood_battery": "n/a: no '!' in the PR title and no (narrowing) arm",
      "mcp_calls": "3: mcp__github__issue_read x3 (get, get_comments x2), reads only",
      "api_writes": "3: POST /repos/objectstack-ai/objectstack/pulls (pr_create, draft), POST /issues/31787/assignees (os-steve, claim Account:), POST /issues/31723/comments (this report). Plus git push, which is not REST.",
      "files_changed": [
        "packages/services/service-cluster/src/cluster-resync.ts",
        "packages/services/service-cluster/src/index.ts",
        "packages/services/service-cluster/src/cluster-resync.test.ts",
        "packages/services/service-cluster-redis/src/client.ts",
        "packages/services/service-cache/src/cache-service-plugin.ts",
        "packages/services/service-cache/src/cache-service-plugin.topology.test.ts",
        ".changeset/31723-cache-derived-connection-liveness.md"
      ],
      "line_budget": "+368 / -18 across 7 files; production src +151 / -18",
      "deviations": [
        "A second new public member: ClusterDriverLiveness.watchConnection, the shared inner that watchRedisConnection delegates to (the seat's ruling allowed 'a shared inner that takes a liveness'). It is listed in open_questions.",
        "The delta's 'quiet listener' case takes the card's 'never a silent swallow' reading: a private ClusterDriverLiveness logs once per outage, through ctx.logger.",
        "The session-context asked for MCP assignee/reviewer writes. They were skipped per standard order 3; the assignee rode pr_create."
      ],
      "open_questions": [
        {
          "question": "Accept the public member ClusterDriverLiveness.watchConnection(client, source) as the shared inner?",
          "options": [
            "A keep: one listener body; watchRedisConnection and watchClusterDriverConnection both call it",
            "B un-export it by reshaping: watchRedisConnection would need a cluster-shaped argument, an awkward API"
          ],
          "recommendation": "A, because callers that hold a liveness (the driver, pubsub's private one) need a liveness-taking entry"
        },
        {
          "question": "The no-liveness fallback reuses the driver's warning text. Keep it, or log a cache-specific line?",
          "options": [
            "A keep the shared text (one outage style, per ruling 1)",
            "B a cache-specific line (a second line style)"
          ],
          "recommendation": "A, because ruling 1 forbids an own outage line, and the store and its consequences are the same"
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": []
    }

    Stamped 2026-11-09T03:52Z.


    Generated by Claude Code

  7. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

    ACCEPT → PR #31787 comment 6732091332 · head c9c845d2 · 2026-11-09T04:15Z · landing: pr_ready + automerge_enable

  8. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

    落地 · 2026-11-09T04:38Z

    reading value
    PR #31787 MERGED 2026-11-09T04:37Z, merge commit ff8ef4ca (ACCEPT 6732091332; TIER_DEFAULT record posted on the PR)
    #31723 closed by the merge (Fixes #31723)

    Landed:

    • service-cluster has watchClusterDriverConnection and ClusterDriverLiveness.watchConnection, so a cluster driver's connection liveness is watched in one place.
    • The redis watchRedisConnection now delegates to it, and the cache's watchDerivedConnection uses it as well (ruling A).
  9. removed
    pm:dispatched
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdomain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions