Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Unable to establish connection on channel when hot restart #142

Conversation

rohitsangwan01
Copy link
Contributor

@rohitsangwan01 rohitsangwan01 commented Feb 21, 2025

PR Type

Bug fix


Description

  • Fixed an issue with channel connection errors during hot restart.

  • Added conditional logging to ignore specific "channel-error" codes.


Changes walkthrough 📝

Relevant files
Bug fix
universal_ble_plugin.h
Improved error handling in `ErrorCallback` method               

windows/src/universal_ble_plugin.h

  • Modified ErrorCallback to conditionally log errors.
  • Added logic to ignore "channel-error" during hot reload.
  • +5/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Error Handling

    The error handling now silently ignores channel-error codes. Consider adding debug logging for these cases to help with troubleshooting.

    // Ignore ChannelConnection Error, This might occur because of HotReload
    if (error.code() != "channel-error")
    {
        std::cout << "ErrorCode: " << error.code() << " Message: " << error.message() << std::endl;
    }

    Copy link

    codiumai-pr-agent-free bot commented Feb 21, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Improve error handling and logging

    Consider adding a debug log for channel errors to help with troubleshooting
    during development, while still maintaining the ignore functionality.

    windows/src/universal_ble_plugin.h [77-81]

    -// Ignore ChannelConnection Error, This might occur because of HotReload
    -if (error.code() != "channel-error")
    -{
    -    std::cout << "ErrorCode: " << error.code() << " Message: " << error.message() << std::endl;
    +// Handle ChannelConnection Error differently during HotReload
    +if (error.code() == "channel-error") {
    +    spdlog::debug("Ignoring channel error during hot reload: {}", error.message());
    +} else {
    +    spdlog::error("BLE Error - Code: {} Message: {}", error.code(), error.message());
     }
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion improves error handling by adding debug logging for ignored channel errors, which enhances debugging capabilities while maintaining the intended hot reload functionality. This provides better visibility into the system's behavior.

    Medium
    Use proper logging mechanism

    Consider using a logging framework or system logger instead of std::cout for
    error handling. Direct console output is not recommended for production code.

    windows/src/universal_ble_plugin.h [80]

    -std::cout << "ErrorCode: " << error.code() << " Message: " << error.message() << std::endl;
    +spdlog::error("BLE Error - Code: {} Message: {}", error.code(), error.message());
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    __

    Why: Using a proper logging framework instead of std::cout is a good practice for production code, offering better control over log levels and output formatting. However, this is more of a code quality improvement rather than a critical fix.

    Low
    • Update

    @rohitsangwan01 rohitsangwan01 merged commit bc19a65 into main Feb 21, 2025
    1 check passed
    @rohitsangwan01 rohitsangwan01 deleted the fix-unable-to-establish-connection-on-channel-when-hot-restart branch February 21, 2025 13:57
    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.

    2 participants