Skip to content

fix(discord): harden voice DAVE receive reliability#25909

Merged
steipete merged 1 commit intomainfrom
fix/discord-voice-dave-reliability
Feb 25, 2026
Merged

fix(discord): harden voice DAVE receive reliability#25909
steipete merged 1 commit intomainfrom
fix/discord-voice-dave-reliability

Conversation

@steipete
Copy link
Contributor

@steipete steipete commented Feb 25, 2026

Summary

  • Restore @snazzah/davey runtime dependency for Discord VC DAVE support.
  • Reimplement and consolidate the strongest pending reliability fixes from related PRs:
  • Add first-class Discord voice DAVE config passthrough:
    • channels.discord.voice.daveEncryption
    • channels.discord.voice.decryptionFailureTolerance
  • Add controlled recovery for repeated decrypt failures (DecryptionFailed(...)) by triggering a rejoin attempt.
  • Add a dedicated regression suite for Discord voice manager lifecycle + DAVE behavior.

Why

Discord inbound STT is currently unreliable under DAVE receive failures (DecryptionFailed(UnencryptedWhenPassthroughDisabled)). This patch addresses the reliability regressions in OpenClaw's voice session lifecycle while exposing upstream DAVE knobs and improving recovery behavior.

Related

Validation

  • pnpm lint
  • pnpm build
  • pnpm test
  • pnpm vitest run src/discord/voice/manager.test.ts

Dependency check (@snazzah/davey)

  • npm latest: 0.1.9 (published 2025-12-19)
  • npm downloads (last week): ~18k
  • repo activity: updated 2026-02-21

Mintlify

0 threads from 0 users in Mintlify

  • No unresolved comments

Open in Mintlify Editor

Greptile Summary

This PR hardens Discord voice DAVE receive reliability by restoring the @snazzah/davey runtime dependency, adding first-class DAVE config passthrough (daveEncryption, decryptionFailureTolerance), implementing stale connection event guards, cleaning up voice listeners on session teardown, and adding a controlled rejoin recovery mechanism for repeated decrypt failures.

  • Restores @snazzah/davey as a runtime dependency for @discordjs/voice DAVE encryption support
  • Adds channels.discord.voice.daveEncryption and channels.discord.voice.decryptionFailureTolerance config options with full schema, help text, labels, and documentation
  • Guards Disconnected/Destroyed event handlers against stale connections using a clearSessionIfCurrent identity check, preventing accidental removal of new sessions when old connection events fire
  • Properly removes all event listeners (speaking, disconnected, destroyed, player error) during stop(), preventing listener leaks across session lifecycle
  • Implements threshold-based decrypt failure recovery: after 3 DecryptionFailed(...) errors within a 30-second window, triggers a leave+rejoin cycle with a decryptRecoveryInFlight guard to prevent concurrent recovery attempts
  • Adds a dedicated regression test suite covering stale event guards, listener cleanup, DAVE option passthrough, and decrypt failure recovery

Confidence Score: 4/5

  • This PR is safe to merge — the changes are well-structured with proper edge case handling and regression tests.
  • The code changes are logically sound: stale event guards use connection identity checks, listener cleanup order is correct (remove listeners before destroy), the decrypt recovery mechanism has proper guard flags to prevent concurrent recovery, and the session lifecycle is well-managed. Config additions are complete across types, Zod schema, help text, labels, and docs. The new test suite covers the critical regression scenarios. Score is 4 rather than 5 because the decrypt recovery flow involves fire-and-forget async operations that could benefit from additional integration testing under real Discord conditions.
  • src/discord/voice/manager.ts — primary logic changes for DAVE recovery and session lifecycle hardening

Last reviewed commit: 9cd50c5

Reimplements and consolidates related work:
- #24339 stale disconnect/destroyed session guards
- #25312 voice listener cleanup on stop
- #23036 restore @snazzah/davey runtime dependency

Adds Discord voice DAVE config passthrough, repeated decrypt failure
rejoin recovery, regression tests, docs, and changelog updates.

Co-authored-by: Frank Yang <frank.ekn@gmail.com>
Co-authored-by: Do Cao Hieu <admin@docaohieu.com>
@cursor
Copy link

cursor bot commented Feb 25, 2026

PR Summary

Medium Risk
Touches Discord voice connection lifecycle and introduces auto-rejoin logic, which could cause unexpected disconnect/reconnect behavior if thresholds or event handling are wrong, but changes are scoped and covered by new tests.

Overview
Improves Discord voice session stability under DAVE by restoring the @snazzah/davey dependency, adding configurable join passthrough (channels.discord.voice.daveEncryption and channels.discord.voice.decryptionFailureTolerance), and documenting the new options.

Hardens DiscordVoiceManager lifecycle by cleaning up listeners on stop and guarding against stale disconnect/destroy events from previous connections, plus adds controlled recovery that triggers a leave+rejoin after repeated DecryptionFailed(...) receive errors within a time window. A new vitest suite covers session replacement, listener teardown, DAVE option passthrough, and decrypt-failure rejoin behavior.

Written by Cursor Bugbot for commit 9cd50c5. This will update automatically on new commits. Configure here.

@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation channel: discord Channel integration: discord gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Feb 25, 2026
@steipete steipete merged commit 9cd50c5 into main Feb 25, 2026
12 checks passed
@steipete steipete deleted the fix/discord-voice-dave-reliability branch February 25, 2026 00:20
@steipete
Copy link
Contributor Author

Landed via fast-forward to main.

Included commit:

What was landed:

Validation run before landing:

  • pnpm lint
  • pnpm build
  • pnpm test

Thanks everyone who contributed the prior PRs/issues and repro detail.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9cd50c51b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

logger.warn(`discord voice: decrypt recovery leave failed: ${leaveResult.message}`);
return;
}
const result = await this.join({ guildId: entry.guildId, channelId: entry.channelId });

Choose a reason for hiding this comment

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

P2 Badge Revalidate active target before recovery rejoin

After recoverFromDecryptFailures calls leave, it always issues join back to the old entry.channelId without checking whether another join request has started meanwhile. In the concurrent case (for example, an operator runs /vc join to a different channel while decrypt recovery is in flight), this stale recovery path can race and pull the bot back to the previous channel or leave multiple live connections competing for the same guild, causing unstable voice behavior.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord voice decrypt failure breaks inbound STT (UnencryptedWhenPassthroughDisabled)

1 participant