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

[PLA-2087] Panics main thread on subscription panic #67

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

leonardocustodio
Copy link
Contributor

@leonardocustodio leonardocustodio commented Nov 20, 2024

PR Type

enhancement


Description

  • Introduced SubscriptionJob struct to manage subscription tasks, replacing the previous SubscriptionParams.
  • Added methods in SubscriptionJob to start block and runtime subscriptions, enhancing the subscription handling mechanism.
  • Integrated SubscriptionJob in the main function, replacing SubscriptionParams and starting the job.
  • Implemented a panic hook in SubscriptionJob to exit the process on panic, improving error handling.

Changes walkthrough 📝

Relevant files
Enhancement
lib.rs
Export `SubscriptionJob` in library module                             

src/lib.rs

  • Added SubscriptionJob to the list of public exports.
+1/-1     
main.rs
Integrate `SubscriptionJob` in main function                         

src/main.rs

  • Replaced SubscriptionParams with SubscriptionJob.
  • Initialized and started SubscriptionJob.
  • +5/-3     
    subscription.rs
    Implement `SubscriptionJob` for managing subscriptions     

    src/subscription.rs

  • Introduced SubscriptionJob struct to manage subscription tasks.
  • Added methods to start block and runtime subscriptions.
  • Implemented panic hook to exit process on panic.
  • +44/-12 

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Error Handling
    The panic hook set in SubscriptionJob::start exits the process immediately upon any panic. This approach might not allow for proper cleanup or logging. Consider implementing a more graceful error handling strategy.

    Thread Safety
    Ensure that the shared state managed by Arc<Mutex<>> in SubscriptionParams is accessed and modified safely across asynchronous tasks to prevent data races.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Improve error handling in the panic hook to avoid abrupt process termination

    Replace the process exit on panic in SubscriptionJob::start with a more resilient
    error handling strategy. Exiting the process can be too drastic for recoverable
    errors and might not allow for proper cleanup or error logging.

    src/subscription.rs [31-35]

     panic::set_hook(Box::new(move |panic_info| {
         orig_hook(panic_info);
    -    process::exit(1);
    +    // Implement a more resilient error handling strategy here
     }));
    Suggestion importance[1-10]: 7

    Why: The suggestion correctly identifies a potential issue with using process::exit in a panic hook, which can prevent proper error handling and cleanup. Implementing a more resilient strategy could improve the robustness of the application.

    7

    @leonardocustodio leonardocustodio merged commit 24ba4dd into master Nov 20, 2024
    12 checks passed
    @leonardocustodio leonardocustodio deleted the PLA-2087 branch November 20, 2024 15:01
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Development

    Successfully merging this pull request may close these issues.

    2 participants