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

Add automatic retry to stream logs #23098

Merged
merged 1 commit into from
Dec 2, 2024
Merged

Add automatic retry to stream logs #23098

merged 1 commit into from
Dec 2, 2024

Conversation

wendevlin
Copy link
Contributor

Proposed change

  • Retry streaming logs when an error occurs to fix:
    • Firefox service worker is intercepting stream
    • there are possibilites of connection issues

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@wendevlin wendevlin added this to the 2024.12 milestone Dec 2, 2024
@@ -226,6 +226,25 @@ export const fetchHassioLogsFollow = async (
signal
);

export const fetchHassioLogsFollowSkip = async (
Copy link
Member

Choose a reason for hiding this comment

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

Why adding a new command instead of adding an option param to the existing fetchHassioLogsFollow command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it because the skip is more complex and needs the cursor and skip lines as addition parameters. But if you want I can rewrite fetchHassioLogsFollow

@@ -554,6 +578,13 @@ class ErrorLogCard extends LitElement {
if (err.name === "AbortError") {
return;
}

// The stream can fail if the connection is lost or firefox service worker intercept the connection
if (!retry && streamLogs) {
Copy link
Member

Choose a reason for hiding this comment

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

This can now also cause an infinite loop I guess? Can we make this check more specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There shoulnd't be. Retry is set to false when the first chunk rendered successfully so we say we are in a healty state again. If it fails again beforehand we show the error.

@bramkragten bramkragten merged commit c3942d2 into dev Dec 2, 2024
16 checks passed
@bramkragten bramkragten deleted the retry-streaming-logs branch December 2, 2024 20:30
bramkragten pushed a commit that referenced this pull request Dec 2, 2024
@bramkragten bramkragten mentioned this pull request Dec 2, 2024
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