Skip to content

fix(streaming): harden Redis ACK handling and document topics#7

Merged
jrb00013 merged 13 commits into
devfrom
bao_t/feature/kafka-redis-streams-integration
May 9, 2026
Merged

fix(streaming): harden Redis ACK handling and document topics#7
jrb00013 merged 13 commits into
devfrom
bao_t/feature/kafka-redis-streams-integration

Conversation

@BaoT1301
Copy link
Copy Markdown
Member

@BaoT1301 BaoT1301 commented Apr 18, 2026

IMPORTANT:

  • PR must be opened from your personal branch -> dev
  • You must tag @Team-Deepiri/support-team
  • You must update Plaky to "Needs QA"
  • Never move a feature/bug to "Done" (Done = production release only)

Description

Hardens the shared Redis Streams client ACK behavior and exposes typed document stream topic constants for the current Deepiri data-streaming contract.

Include:

  • Related Issue number: N/A
  • Plaky feature name: Deepiri shared Redis Streams foundation
  • Component, feature, or system affected: @deepiri/shared-utils streaming client and topic registry
  • Purpose of change: bug fix + shared contract improvement + CI fix

Changes

  • Moved Redis XACK handling outside callback failure paths so callback errors do not leave messages stuck in the pending entries list.
  • Classified ACK failures with visible root-cause logging for real Redis cases versus defensive handling.
  • Added tests for ACK failure classification and retry/log behavior.
  • Added document.vectorize, document.training, document.structured, and document.artifacts constants to StreamTopics.
  • Added tests locking the document.* topic constant values.
  • Added working CI with Node 20, npm install, build, and tests; removed the broken custom CodeQL workflow conflict with GitHub Default Setup.
  • Added missing ts-jest dev dependency used by Jest config.

Related


Testing

Verified locally:

  • npm test
  • npm run build

Remote GitHub checks are passing:

  • Build & Test

Additional testing details:

  • ACK failures are classified instead of silently swallowed.
  • Stream topic constants now match the Cyrex document stream consumer contract.

Important Notes (Optional)

  • Known limitations: This PR adds shared topic constants but does not define document event schemas/classes.
  • Blockers: None known in code; review approval still required.
  • CI/CD issues unrelated to this PR: None currently known.
  • Dependencies required for testing: Node 20.

Workflow Checklist (Required)

  • Branch is up to date with dev
  • PR is from your branch -> dev (no longer directly into main)
  • PR title follows convention (feat:, fix:, refactor:, etc.)
  • Plaky feature/bug name included above
  • Tagged @Team-Deepiri/support-team
  • Plaky feature moved to "Needs QA"

Review Requests

@Team-Deepiri/support-team

Moves xack outside the callback error handler so a failed callback
never skips the ACK and causes messages to accumulate in the PEL.
safeAck swallows transient Redis ACK errors to keep the loop alive.
Replaces the Default setup which was incorrectly configured to scan
the 'actions' language (GitHub Actions YAML) — this repo has no custom
action source code, causing the scan to fail with exit code 32.
@austinm2h35-sketch
Copy link
Copy Markdown
Contributor

@JC5467 Go ahead and take care of reviewing this when you can, thank you!

Copy link
Copy Markdown
Member

@jrb00013 jrb00013 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this moved in the catch error exception block now?

@jrb00013 jrb00013 changed the title fix(streaming): always ACK outside callback try-catch via safeAck Fixes ACK outside callback try-catch via safeAck in streaming utilities Apr 21, 2026
@BaoT1301
Copy link
Copy Markdown
Member Author

Hey Joe, the safeAck actually moved after the try catch block, not into the catch. The structure is try callback, catch and log any error then always ACK. The reason is that the old code only ACKed inside the try, so if the callback threw an exception the message was never acknowledged, it'd pile up in the Redis Pending Entry List and be redelivered to the consumer in an infinite loop. Moving it outside the catch makes the ACK unconditional. safeAck is just a thin wrapper that silences transient Redis xack errors so they don't crash the consumer loop.

Comment thread .github/workflows/ci.yml Fixed
@jrb00013
Copy link
Copy Markdown
Member

jrb00013 commented Apr 22, 2026

Should we fix the underlying Redis xack errors to begin with instead of just silencing them?

@jrb00013
Copy link
Copy Markdown
Member

@BaoT1301

@BaoT1301
Copy link
Copy Markdown
Member Author

Hey Joe, I updated the shared StreamingClient ACK handling so we are no longer silently swallowing Redis xack failures.

What I changed:

Kept ACK outside the callback try/catch so callback failures don’t leave messages stuck in PEL.
Replaced silent xack catch with bounded retry/backoff for transient Redis errors.
Added explicit error classification (retryable vs non-retryable) and structured logs with stream/group/message context.
Added logging for xack = 0 cases (already acked/not pending) for observability.
Added unit tests covering success, no-op ack, transient retry success, non-retryable failure, and retry exhaustion.

@jrb00013
Copy link
Copy Markdown
Member

But what about figurting out the underlying Redis xack errors to begin with? Or were they hypothetical

@jrb00013
Copy link
Copy Markdown
Member

jrb00013 commented May 3, 2026

@BaoT1301

1 similar comment
@jrb00013
Copy link
Copy Markdown
Member

jrb00013 commented May 4, 2026

@BaoT1301

@BaoT1301 BaoT1301 changed the title Fixes ACK outside callback try-catch via safeAck in streaming utilities fix(streaming): harden Redis ACK handling and document topics May 7, 2026
@BaoT1301 BaoT1301 changed the base branch from main to dev May 7, 2026 19:54
@jrb00013
Copy link
Copy Markdown
Member

jrb00013 commented May 8, 2026

@BaoT1301 But what about figurting out the underlying Redis xack errors to begin with? Or were they hypothetical

@jrb00013 jrb00013 merged commit 4995701 into dev May 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants