Skip to content

Conversation

@grahamking
Copy link
Contributor

@grahamking grahamking commented Aug 22, 2025

This adds a stack trace to error messages, which was causing the string match to miss.

Later we should try to make this an error type, so we don't have to string match.

This adds a stack trace to error messages, which was causing the string
match to miss.

Later we should try to make this an error type, so we don't have to string match.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 22, 2025

Walkthrough

Adjusted RetryManager::next() stream-termination detection to use err.to_string().starts_with(...), triggering stream recreation on matching errors and logging a warning on failure. Tests initialize logging via dynamo_runtime::logging::init() and some test names were prefixed with underscores. No public API changes.

Changes

Cohort / File(s) Summary
Migration logic
lib/llm/src/migration.rs
Replaced exact Debug-string comparison with err.to_string().starts_with("Stream ended before generation completed") in RetryManager::next(); attempts stream recreation on match; logs warning if recreation fails.
Tests & logging
.../tests/*
Added dynamo_runtime::logging::init() in multiple tests; renamed certain tests to start with an underscore without changing behavior.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Caller
  participant RM as RetryManager
  participant S as Stream
  participant L as Logger

  C->>RM: next()
  RM->>S: poll/receive chunk
  alt chunk received
    S-->>RM: data
    RM-->>C: yield data
  else error from stream
    S-->>RM: error e
    RM->>RM: if e.to_string().startsWith("Stream ended before generation completed")
    alt matches
      RM->>RM: recreate stream
      alt recreation succeeds
        RM-->>C: continue streaming
      else recreation fails
        RM->>L: warn("Failed to recreate stream")
        RM-->>C: propagate error
      end
    else no match
      RM-->>C: propagate error
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A whisk of code, a hop in time,
Streams that end now give a sign.
If errors start the magic phrase,
We forge anew the streaming ways.
Logs do blink—warning lights—
And rabbits ship resilient bytes. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (8)
lib/llm/src/migration.rs (8)

101-110: Harden stream-termination detection to survive context-wrapped errors

Good move switching to Display (to_string) so backtraces don’t poison comparisons. To make this resilient if upstream adds context (e.g., anyhow context chain), match across the error chain instead of only the top-level message.

Apply this diff:

-                    if err.to_string().starts_with(STREAM_ERR_MSG) {
+                    if err.chain().any(|e| e.to_string().starts_with(STREAM_ERR_MSG)) {

Optional follow-up: hoist STREAM_ERR_MSG to a module-level const so tests can reference super::STREAM_ERR_MSG instead of duplicating the literal. I can provide a patch if you want.


463-469: Initialize tracing once across tests to avoid global re-init

dynamo_runtime::logging::init() likely installs a global subscriber. Re-initializing per test can be a no-op or panic depending on implementation. Make it idempotent in tests and call it via a small helper.

Apply this diff here:

-        dynamo_runtime::logging::init();
+        init_test_logging();

Add this once-only helper inside the #[cfg(test)] mod tests (outside individual tests):

use std::sync::Once;
static INIT: Once = Once::new();

fn init_test_logging() {
    INIT.call_once(|| {
        // Ignore the result if init can fail when already initialized
        dynamo_runtime::logging::init();
    });
}

495-501: Same: use once-only logging init in this test

-        dynamo_runtime::logging::init();
+        init_test_logging();

528-532: Same: use once-only logging init in this test

-        dynamo_runtime::logging::init();
+        init_test_logging();

565-571: Same: use once-only logging init in this test

-        dynamo_runtime::logging::init();
+        init_test_logging();

587-587: Underscore-prefixed test names still run; consider renaming back or marking ignored

Leading underscores don’t disable #[tokio::test]. If the intent was to keep them running (and they now pass), prefer consistent names without the underscore. If the intent was to skip, use #[ignore].

Rename back:

-    async fn _test_retry_manager_ongoing_request_migration_indefinite_failure() {
+    async fn test_retry_manager_ongoing_request_migration_indefinite_failure() {
-    async fn _test_retry_manager_ongoing_request_migration_indefinite_failure_stream_error() {
+    async fn test_retry_manager_ongoing_request_migration_indefinite_failure_stream_error() {

Also applies to: 635-635


587-590: Also switch this test to once-only logging init

-        dynamo_runtime::logging::init();
+        init_test_logging();

635-640: Also switch this test to once-only logging init

-        dynamo_runtime::logging::init();
+        init_test_logging();
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b92a805 and 91af17b.

📒 Files selected for processing (1)
  • lib/llm/src/migration.rs (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: Build and Test - dynamo

Thanks!

Also fix my check to take into account anyhow error chains.
@grahamking grahamking enabled auto-merge (squash) August 22, 2025 18:56
@pull-request-size pull-request-size bot added size/M and removed size/S labels Aug 22, 2025
@grahamking grahamking merged commit 819bb62 into main Aug 22, 2025
12 of 14 checks passed
@grahamking grahamking deleted the gk-migration-stack-msg branch August 22, 2025 19:25
hhzhang16 pushed a commit that referenced this pull request Aug 27, 2025
Signed-off-by: Hannah Zhang <hannahz@nvidia.com>
jasonqinzhou pushed a commit that referenced this pull request Aug 30, 2025
Signed-off-by: Jason Zhou <jasonzho@jasonzho-mlt.client.nvidia.com>
KrishnanPrash pushed a commit that referenced this pull request Sep 2, 2025
Signed-off-by: Krishnan Prashanth <kprashanth@nvidia.com>
nnshah1 pushed a commit that referenced this pull request Sep 8, 2025
Signed-off-by: nnshah1 <neelays@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants