-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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 actions fetching logic and loading state, prevent duplicate toasts #31124
base: main
Are you sure you want to change the base?
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. |
Ended up following your suggestion and defaulting to |
I will try to propose a solution to see whether it is better. There are some details in my mind. |
-> Make toast support preventDuplicates #31501 |
I'll merge this now for the bugfix part. We can iterate on the toast in #31501. |
I have objection for backporting, unless TOC agrees to backport. |
And one more thing, could you revert the toast related code? |
I can remove the toast code in favor of #31501 if you port all my changes from here (htmx and actions view I don't really care about the backport so much as I'm not using Actions, but other users might and I think it's a important bugfix for them. |
The problem is that the code really changed a lot and I am not sure there would be regressions, for example:
I think as a bug fix it is really good to end users and the work is awesome, while I also think we should make 1.22 branch as stable as possible to avoid introducing new regressions (especially for a large PR like this) So, maybe if this change is stable enough in 1.23, then we could backport it to the next 1.22 release (eg 1.22.2 or 1.22.3) |
if (!this.currentJobStepsStates[i]) { | ||
// initial states for job steps | ||
this.currentJobStepsStates[i] = {cursor: null, expanded: false}; | ||
if (job) { |
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.
Here and above: why it needs new two if
here? They are from [job, artifacts] = await Promise.all
, and the response shouldn't be null.
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.
If the await Promise.all
fails, none of these 2 variables could have value.
So it should return early in the catch
block above, but not use extra if
blocks here.
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.
I think the root problem is that the state management in this loadData/loadJob
is quite messy (because after the initial version, then people only add code to "patch" it).
As a bug fix, I think this PR could work. While if we'd like to make the code right, I guess we need to rewrite the code and re-design the state management logic. For example, maybe this.loading
doesn't make sense now, we need to track every request's state separately.
(Just some new thoughts)
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.
The if
s are meant to perform a partial state update if one of the two requests fails (which would be caught and show a toast).
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.
But I see you are right, Promise.all
can not deliver partial results, it either resolves both or rejects with the first encountered error, so my interpretion of the return value was wrong and the if
s are not needed.
I think #31501 could satisfy your requirement, it uses |
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. |
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.