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: corrected the disconnection behavior to get stream logs Close #1… #17681

Merged

Conversation

angeliski
Copy link
Contributor

@angeliski angeliski commented May 5, 2023

Hey, I just made a Pull Request!

Hey team, I put a fix for #15002

The problem is described at the issue but the basic is:
We receive a disconnection (internet issues) and don't get any feedback (or update) after that. So I did two things:

  1. Change the empty message to We cannot connect at the moment, trying again in some seconds... Retrying (3/3 retries)
    image
  2. Put a simple retry after 15s using a timeout. In my case I didn't get the backend running again, so I got a Failed to fetch message

image

I tried to change the error behavior from the observable (resulting in the subscriber disconnection). Still, I got a very messy code, so this is a simple enough solution.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • [N/A] Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@angeliski angeliski requested a review from a team as a code owner May 5, 2023 22:52
@angeliski angeliski requested a review from jhaals May 5, 2023 22:52
@github-actions github-actions bot added the area:scaffolder Everything and all things related to the scaffolder project area label May 5, 2023
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented May 5, 2023

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/plugin-scaffolder-react plugins/scaffolder-react patch v1.4.0

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2023

Uffizzi Preview deployment-25612 was deleted.

Copy link
Member

@jhaals jhaals left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

A minor note/question regarding the retry that is forever now if I read the code correctly.
Would it be terrible to add some tests to this hook/functionality to gain some confidence for further refactors?

Would love for @benjdlambert to take a look at this as well.

plugins/scaffolder-react/src/hooks/useEventStream.ts Outdated Show resolved Hide resolved
Copy link
Member

@jhaals jhaals left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

A minor note/question regarding the retry that is forever now if I read the code correctly.
Would it be terrible to add some tests to this hook/functionality to gain some confidence for further refactors?

Would love for @benjdlambert to take a look at this as well.

// details here https://github.com/backstage/backstage/issues/15002

if (!error.message) {
error.message =
Copy link
Member

Choose a reason for hiding this comment

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

Interestingly what is the error type at this point and why does it not have a message?

Copy link
Contributor Author

@angeliski angeliski May 9, 2023

Choose a reason for hiding this comment

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

I just was getting an ERR_NETWORK_CHANGED 200 in the browser, but didn't find a simple way to catch this error in the code, so I used the empty message to change this.

Do you have suggestions on how to catch this?

image

Copy link
Member

Choose a reason for hiding this comment

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

Hmm - I wonder if these are just browser errors and are not available in javascript though. If you stringify the error that you get in the useEventStream and log it what does it look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an event from the EventSource, so just generic information 🤔
image

@angeliski angeliski force-pushed the add-timeout-to-task-event-stream branch from b5c0dc6 to 2015c76 Compare May 10, 2023 12:47
Copy link
Member

@benjdlambert benjdlambert left a comment

Choose a reason for hiding this comment

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

ok let's go with this

@benjdlambert
Copy link
Member

We could really do with tests for this too, but you don't have to do that in this PR.

@jhaals
Copy link
Member

jhaals commented May 15, 2023

Please make sure to run prettier for the build to pass :)

@angeliski angeliski force-pushed the add-timeout-to-task-event-stream branch from 2015c76 to 4b39337 Compare May 16, 2023 21:46
@angeliski
Copy link
Contributor Author

Fixed @jhaals, sorry for this taking so long

@benjdlambert I didn't find a test for the useEventStream hook, Do you expect a test for the whole file or a test in another place?
I will to raise test for this soon

@jhaals
Copy link
Member

jhaals commented May 17, 2023

@benjdlambert I didn't find a test for the useEventStream hook, Do you expect a test for the whole file or a test in another place? I will to raise test for this soon

I think it make sense to add a new test for the useEventStream file and add some cases for this :) Would be lovely as a followup PR 🙏

@jhaals
Copy link
Member

jhaals commented May 17, 2023

@angeliski if you rebase this PR against master the build should go green 🤞

…ckstage#15002

Signed-off-by: Rogerio Angeliski <angeliski@hotmail.com>
@angeliski angeliski force-pushed the add-timeout-to-task-event-stream branch from 4b39337 to 84a5c77 Compare May 17, 2023 11:18
@benjdlambert benjdlambert merged commit 9dbd753 into backstage:master May 17, 2023
26 of 28 checks passed
@benjdlambert
Copy link
Member

Our e2e's are b0rked right now because of another octokit issue.

@github-actions
Copy link
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.15.0 release, scheduled for Tue, 20 Jun 2023.

@benjdlambert
Copy link
Member

But merged this anyways 🙏 Thanks @angeliski

@angeliski angeliski deleted the add-timeout-to-task-event-stream branch May 29, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:scaffolder Everything and all things related to the scaffolder project area
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants