Skip to content

Conversation

@robindiddams
Copy link
Member

@robindiddams robindiddams commented May 23, 2025

  • fixes prepareStackTrace to not crash the program when we cant sugar up the err stack
  • adds a lot more (hopefully useful) trace logging to devmode server
  • fixes a bug in the devmode logger to not drop early logs
  • shards the devmode session based on project id
  • apiclient will now return context errors directly without wrapping them
  • ctrl + c does not show connection context cancelled during a startup

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for stack trace processing, ensuring original stack traces are shown if an internal error occurs.
    • Enhanced server connection error reporting and logging for better clarity and observability.
    • Fixed handling of context cancellation during server connection and API requests to prevent unnecessary error messages and ensure clean exits.
  • Refactor

    • Updated internal server logic to use more accurate error channels and improved context handling for API requests.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 23, 2025

Walkthrough

The changes introduce enhanced error handling in the stack trace preparation logic and add detailed trace-level logging to the server connection process. The server's logger initialization order is adjusted, server ID generation now uses the project ID, and OpenTelemetry attributes are updated. API client initialization now uses the correct context. Additional improvements include handling context cancellation errors in the dev command and API client HTTP request execution.

Changes

File(s) Change Summary
internal/bundler/shim.go Wrapped stack trace preparation logic in a try-catch; returns original stack on error; minor code reorganization.
internal/dev/server.go Changed connected channel type to chan error; added trace-level logging in connection process; adjusted logger init order; changed server ID to project ID; updated OpenTelemetry attributes; API client uses server context.
cmd/dev.go Added handling for context.Canceled error to cleanly close UI without error logging on cancellation.
internal/util/api.go Added explicit handling for context cancellation and deadline exceeded errors in HTTP request execution to avoid wrapping these errors.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant Logger
    participant DevModeServer
    participant APIClient

    Client->>Server: Connect()
    Server->>Logger: Trace "Starting connection"
    Server->>Logger: Trace "Refreshing connection metadata"
    Server->>Logger: Trace "Dialing devmode server"
    Server->>DevModeServer: Dial()
    Server->>APIClient: Initialize with server context
    Server-->>Client: Connection established or error
Loading

Possibly related PRs

Poem

A bunny hops through logs and stacks,
With trace and catch, it covers its tracks.
Context flows with every leap,
Project IDs it now will keep.
If errors rise or logs abound,
The rabbit’s code is safe and sound!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4142d8c and 01aca07.

📒 Files selected for processing (3)
  • cmd/dev.go (2 hunks)
  • internal/dev/server.go (7 hunks)
  • internal/util/api.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/dev/server.go
🧰 Additional context used
🪛 GitHub Actions: PR #343
internal/util/api.go

[error] 22-22: No required module provides package github.com/agentuity/go-common/logger; to add it: run 'go get github.com/agentuity/go-common/logger'.

🔇 Additional comments (4)
internal/util/api.go (2)

178-180: LGTM: Proper context error handling.

The explicit handling of context.Canceled and context.DeadlineExceeded errors is excellent practice. These errors represent normal operational conditions (timeouts, user cancellation) rather than API failures, so returning them directly without wrapping allows upstream code to handle them appropriately.


22-22:

Details

✅ Verification successful

Resolve the missing dependency issue.

The pipeline is failing because the github.com/agentuity/go-common/logger module is not available. This needs to be resolved before the changes can be merged.

Please run the following command to add the missing dependency:


🏁 Script executed:

#!/bin/bash
# Check if the go-common module exists and what version should be used
go get github.com/agentuity/go-common/logger

Length of output: 591


Dependency go-common/logger now available
The import github.com/agentuity/go-common/logger resolves successfully (v1.0.64). To finalize:

  • Run go mod tidy to update go.mod and go.sum.
  • Commit the updated go.mod and go.sum files.
🧰 Tools
🪛 GitHub Actions: PR #343

[error] 22-22: No required module provides package github.com/agentuity/go-common/logger; to add it: run 'go get github.com/agentuity/go-common/logger'.

cmd/dev.go (2)

5-5: Good addition for error handling.

Adding the errors package import supports the improved context cancellation handling below.


127-130: Excellent context cancellation handling.

This change provides a much better user experience by handling context.Canceled errors gracefully. Context cancellation typically occurs during normal shutdown (e.g., user pressing Ctrl+C), so treating it as an error condition and logging it would be confusing. The immediate return with clean UI closure (ui.Close(true)) is the appropriate response.

This aligns well with the context error handling improvements in internal/util/api.go.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • 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.

@robindiddams robindiddams merged commit 08b0d17 into main May 23, 2025
14 checks passed
@robindiddams robindiddams deleted the improve-devmode-loggin branch May 23, 2025 19:33
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.

2 participants