-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix components event dispatch ordering + E2E test fixes #10112
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 components event dispatch ordering + E2E test fixes #10112
Conversation
{ | ||
var info = deferredIncomingEvents.Dequeue(); | ||
var task = DispatchEventAsync(info.EventHandlerId, info.EventArgs); | ||
task.ContinueWith(_ => |
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.
Is there a really good reason to use ContinueWith
here instead of await
. I know there's no scheduler in this use case, but it's seemed like we've had bugs in most of our usage of ContinueWith
so I like to avoid it.
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 was just avoiding async void
since there's no drawback to the ContinueWith
here. However it doesn't really matter, so based on your preference I've changed this now.
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.
You can also async Task
and then invoke it as fire-and-forget.
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 that would be more misleading. It suggests the upstream code is responsible for error handling.
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.
We should try to get this in and stabilize things ASAP
Holly molly. I'm glad that we found that. I actually noticed the RenderRegistry change, I just didn't realize the implications. It might have been an oversight on my part too, as the change was in a commit after I signed off on the PR I might have dismissed it as minor and didn't think that much of it. WRT big PRs I agree. The smaller the better. |
Not your fault. I wrote that code! I am also a bit shaken that we got so close to shipping such a bad bug (security implications, but only once your site gets to a high level of traffic -- absolutely the worst). I'm taking it as a lesson to hunt down anything weird relentlessly, and not wave it away with vague ideas that external things (Selenium, in this case) might just be unreliable. |
I eventually found that the newly-introduced components E2E test flakiness was actually due to a real product bug that I created in the "key support" feature.
As a workaround to what seems like a Chrome bug (or at least a bizarre inconsistency between Chrome and Firefox), I had put in some new logic to ensure events are only ever dispatched in series, and are not nested inside each other. This was only intended to affect client-side execution, since the same problem can't occur on the server because of its sync context. However, I made a mistake and put the change into
RendererRegistryEventDispatcher
which is actually shared between server and client (I had thought it was client only). Therefore the queuing system I implemented was inadvertently being shared across all users on the server, creating random timing effects where it's possible for one user's event to be dispatched to a different user. Hence the interference between simultaneous tests.The fix here is to move the new dispatch logic into a place where it really only runs on the client, where there really only is one user.
Secondly, while trying to verify this through E2E tests, I noticed that we were missing server-side execution coverage for some of the E2E test classes. Once I added that, I found that some minor tweaks were needed to create consistency between the two environments and have all tests pass everywhere.
What we can learn from this: