-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix actions fetching logic and loading state, prevent duplicate toasts #31124
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
Conversation
Could we split these as two PRs for easier review? |
Can't easily split this because if I remove only the toast changes, there would be the problem of repeated error toasts every second because of that refresh mechanism. The only thing that could be done is to have a reduced backport that only fixes issue 1 with the force flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this review request.
No block from my side (I don't use Actions and I haven't spent time on reading code), just share some opinions:
- the loadData state management becomes more and more complex and fragile, at first glance I can't tell whether it is complete but I guess there could be some edge cases, for example:
force=true
will reset otherthis.loading=true
- maybe there should be some tests to cover some functions (even without e2e test, we could mock and test some code blocks)
- the change of
showToast
is quite hackypreventDuplicates
should not default to true, it is a breaking behavior.- it should hide the existing toast, but not skip the new toast.
- it shouldn't be backported since the change is not covered by tests, and it doesn't fix blocker problems for end users.
Quite hard I assume unless Vue works in happy-dom, but I would doubt that. Maybe with some Vue-specific testing framework, but I have no experience with those.
It helps with other cases like systems stats flooding the page with error toasts when going offline.
This is actually a nice idea, I will try to implement.
It's quite annoying when you click an action step and nothing happens though. Happens to me like a third of the time. |
Will also fix the boolean trap with |
Maybe something like "Improve |
Right, this BTW, I think I will extract the toast changes to another PR. I have a few improvements in mind. |
Ah, I see you went with the "default enabled" variant, so yes in this case we don't need to special-case these callers. I will remove all toast-related code from this commit. |
OK, I am sure the state management is not right now. See the duplicate lines: That's my first worry in #31124 (review) |
@silverwind you edited my comment ...... (reverted) To answer:
I think the reason is still related to the "force" behavior: to produce, make the backend sleep 500-1500ms to respond to make the edge cases could easily be triggered, then toggle the steps multiple times, then since you use |
Sorry, meant to reply. I will rework this later. |
FYI https://codeberg.org/forgejo/forgejo/pulls/6122 is related and deals with the same bug of the job step sometimes not expanding. |
Just take a quick look, I do not think it is right, it seems to be a hacky patch. |
I will try to work on it in the following few days, to see whether we could properly fix it in 1.23 |
Thanks, I haven't gotten around to this. I hope you can reproduce the issue. It happens when a job is expanded while the fetch is still running. |
Done, see this: Refactor RepoActionView.vue #32713 |
async loadJob() { | ||
if (this.loading) return; | ||
async loadData({force = false} = {}) { | ||
if (this.loading && !force) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the event that a force request is received, I think that there will be a race condition that may cause a similar problem to the one that you're attempting to solve, occasionally:
There's loadData(A) which was already running, and then loadData(B) which was running with the force flag. If loadData(B) returns from the server first, and then loadData(A)'s data returns from the server afterwards, I believe the log data will be reverted back to the data from the first request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's why I blocked this PR from merging #31124 (comment)
Replaced by #32713 ? |
Yes, that includes the most important fix. As for the other 2 topics, I think we can do them another time. |
force
flag.throw
the error and the browser would dump it into the console, invisible to the user. Show a toast in such a case.cursor
remains atnull
, for example when a fetch error happened.Also, because in the actions view, fetches can fail repeatedly because of the refreshing, I saw the need to introduce a deduplication for toasts, so if an attempt is made to raise a toast with the same message and level, it will suppress opening them.