Skip to content

Conversation

@mattsloan-dg
Copy link

@mattsloan-dg mattsloan-dg commented Oct 16, 2025

Add bug reports for the connection.start_listening() method's blocking behavior and misleading documentation.

The start_listening() method blocks indefinitely, preventing subsequent code from executing, which is not clear from its name or the current documentation examples. These reports clarify the expected blocking behavior, provide correct usage patterns (threading/async tasks), and suggest documentation updates or API changes to improve user experience.


Open in Cursor Open in Web

Summary by CodeRabbit

  • Documentation
    • Added comprehensive analysis and bug report documenting the blocking behavior of the start_listening() method.
    • Documented correct usage patterns using threading and asyncio approaches to prevent blocking.
    • Clarified discrepancies between documented examples and actual implementation behavior across multiple socket client versions.

Co-authored-by: matt.sloan <matt.sloan@deepgram.com>
@cursor
Copy link

cursor bot commented Oct 16, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Walkthrough

Two new documentation files are added to the repository: BUG_ANALYSIS_SUMMARY.md and BUG_REPORT.md. These files document a blocking behavior issue in the start_listening() method across socket_client implementations, detailing the problem, affected code locations, observable behavior, and recommended usage patterns with suggested fixes.

Changes

Cohort / File(s) Summary
Bug Documentation
BUG_ANALYSIS_SUMMARY.md, BUG_REPORT.md
New markdown files documenting the blocking behavior of start_listening() method in socket_client implementations. Details the problem (indefinite blocking due to internal infinite loop), affected files, observable behavior differences between tests and production, misleading documentation examples, correct usage patterns (threading/asyncio), and suggested fixes (update docs, add non-blocking helpers, rename method).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Investigate connection start listening bug" is clearly related to the changeset content. The PR adds two detailed documentation files (BUG_ANALYSIS_SUMMARY.md and BUG_REPORT.md) that investigate and analyze the blocking behavior of the connection.start_listening() method, making the title specifically accurate to the bug being addressed. While the title uses a somewhat generic verb ("Investigate") and doesn't fully convey that the PR delivers formal bug reports, analysis, and recommendations, it is specific and clear enough that a teammate scanning the repository history would immediately understand this addresses a documented issue with the start_listening() method. The title is partially related to the changeset—it identifies the specific bug being addressed rather than using truly vague terms like "misc updates."
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/investigate-connection-start-listening-bug-432c

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mattsloan-dg mattsloan-dg marked this pull request as ready for review October 16, 2025 21:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
BUG_ANALYSIS_SUMMARY.md (1)

1-118: Substantive overlap with BUG_REPORT.md — Both files document the same issue with similar code examples, affected files, and solutions. The distinction between the two files is unclear:

  • BUG_REPORT.md is more formal and comprehensive, with explicit "Root Cause" and "Affected Files" sections.
  • BUG_ANALYSIS_SUMMARY.md is more conversational (with emoji formatting) and includes the useful "Why Tests Pass" section.

Consider whether both files serve distinct purposes (e.g., bug report for issue tracking vs. analysis for developer documentation) or if they should be consolidated into a single document to avoid duplication and maintenance burden.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d86216 and dba0cbb.

📒 Files selected for processing (2)
  • BUG_ANALYSIS_SUMMARY.md (1 hunks)
  • BUG_REPORT.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
BUG_ANALYSIS_SUMMARY.md

[grammar] ~3-~3: There might be a mistake here.
Context: ...ing()Blocking Issue ## 🐛 The Problem You're experiencing a bug whereconnect...

(QB_NEW_EN)


[grammar] ~7-~7: There might be a mistake here.
Context: ...orly documented. ## 🔍 What's Happening The start_listening() method contains ...

(QB_NEW_EN)


[grammar] ~30-~30: There might be a mistake here.
Context: ...tion closes. ## 📚 Documentation Issues ### Misleading Examples The documentation s...

(QB_NEW_EN)


[grammar] ~68-~68: There might be a mistake here.
Context: ...a(audio_bytes) ``` ## 🔧 Why Tests Pass Tests work because they use **mock webso...

(QB_NEW_EN)


[grammar] ~104-~104: There might be a mistake here.
Context: ... behavior explicit ## 📁 Affected Files - src/deepgram/listen/v1/socket_client.py - src/deepgram/listen/v2/socket_client.py - src/deepgram/speak/v1/socket_client.py - src/deepgram/agent/v1/socket_client.py - websockets-reference.md - README.md ## 🎯 Next Steps 1. ✅ Bug identified and d...

(QB_NEW_EN)


[grammar] ~113-~113: There might be a mistake here.
Context: ...ence.md-README.md` ## 🎯 Next Steps 1. ✅ Bug identified and documented 2. ⏭️ Fi...

(QB_NEW_EN)

🔇 Additional comments (8)
BUG_REPORT.md (5)

1-6: Clear problem statement and summary — The issue is well-defined: start_listening() blocks indefinitely and prevents subsequent code execution, which is not clearly documented. This accurately captures the core user-facing problem.


96-142: Recommendations are actionable and well-reasoned — Three options are presented with clear trade-offs: Option 1 (documentation fix, low-risk), Option 2 (non-blocking helper, better UX, non-breaking), and Option 3 (rename method, most explicit but breaking). However, the PR objectives mention "suggested fixes" but it's unclear which recommendation this PR proposes to implement. Clarify which option(s) this PR addresses or if it is purely documentation of the issue.


144-157: Related files correctly document working implementations — The list of example files shows that both sync (with threading) and async (with asyncio.create_task) implementations already exist in the codebase and use correct patterns. However, the statement "But the documentation doesn't reflect this requirement!" highlights a critical gap. Verify that the main documentation files (websockets-reference.md, README.md) indeed lack these correct patterns before finalizing this report.


7-41: Verification confirmed: File paths, line numbers, and code snippets are accurate.

All referenced files exist with correct line numbers. The code at the specified ranges matches the review snippets exactly, confirming the blocking for-loop pattern in both synchronous and asynchronous start_listening() implementations across src/deepgram/listen/v1/socket_client.py and other socket client modules. The root cause analysis is sound and well-illustrated.


50-67: Documentation examples are accurate — The examples showing blocking behavior after start_listening() are confirmed present in both websockets-reference.md and README.md. The files contain code patterns where sequential calls appear after start_listening(), which aligns with the blocking behavior documented in BUG_REPORT.md. These documentation inconsistencies correctly identify misleading examples that could confuse developers.

BUG_ANALYSIS_SUMMARY.md (3)

1-28: Problem explanation and "What's Happening" sections are clear — The infinite loop pattern is well-explained with a concrete code example. The before/after illustration of code that never executes is effective for user understanding. Verify that the characterization of the blocking behavior is accurate and complete (e.g., confirm the loop truly never returns until connection closes).


113-118: Next Steps checklist indicates preliminary stage — The checklist marks "Bug identified and documented" as complete (✅) and lists "Fix documentation," "Add helper methods," and "Add warnings" as pending (⏭️). This confirms the PR is the initial documentation of the issue. Clarify in the PR description or commit message whether this PR intends to:

  1. Track the issue only (no code changes), or
  2. Also include implementations of one or more recommendations, or
  3. Link to related issues/PRs that implement the fixes.

68-70: Unable to verify the websocket mock claim from the codebase.

Despite searching for test implementations of start_listening(), socket clients, websocket mocking patterns, and finite message fixtures, no supporting test code was found. Socket implementations exist (src/deepgram/listen/v1/socket_client.py, v2, etc.), but corresponding test implementations that demonstrate mock websockets with finite message returns could not be located.

The claim that "Tests work because they use mock websockets that return a finite set of messages and then stop" requires manual verification by checking:

  1. Which tests actually cover the socket/listening functionality
  2. How those tests mock websocket behavior
  3. Whether mocked websockets are configured to return finite message sequences

Copy link
Contributor

@jpvajda jpvajda left a comment

Choose a reason for hiding this comment

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

@mattsloan-dg I'm not quite clear why this is. PR. it seems to be a bug you are reporting?

@lukeocodes lukeocodes marked this pull request as draft October 30, 2025 11:47
@mattsloan-dg
Copy link
Author

@jpvajda We can close this PR. It was auto generated by a Cursor Agent when I asked it about our Python 5.0.0 SDK - https://cursor.com/agents?selectedBcId=bc-18dd782c-0431-438f-afbc-6e6885e9f040

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