Hey, the context for this fix:
https://issues.chromium.org/issues/467448815#comment34
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Hey, the context for this fix:
https://issues.chromium.org/issues/467448815#comment34
Thank you!
event_router()->DispatchEventToExtension(ext1, std::move(event));Uhm... If this case is not properly handling, do you know why [this test](https://crsrc.org/c/chrome/browser/extensions/api/web_request/web_request_apitest.cc;drc=2619b946b249d21cc1f2f1e08edcec3ecb8fdc4e;l=6927) is not failing?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
event_router()->DispatchEventToExtension(ext1, std::move(event));Uhm... If this case is not properly handling, do you know why [this test](https://crsrc.org/c/chrome/browser/extensions/api/web_request/web_request_apitest.cc;drc=2619b946b249d21cc1f2f1e08edcec3ecb8fdc4e;l=6927) is not failing?
Oh I see. In the case you're covering, there's no lazy listener either...?
event_router()->DispatchEventToExtension(ext1, std::move(event));Andrea OrruUhm... If this case is not properly handling, do you know why [this test](https://crsrc.org/c/chrome/browser/extensions/api/web_request/web_request_apitest.cc;drc=2619b946b249d21cc1f2f1e08edcec3ecb8fdc4e;l=6927) is not failing?
Oh I see. In the case you're covering, there's no lazy listener either...?
Yes, the case that I am covering is when webRequest doesn't have a listener or a lazy listener, but the caller of the API think that there might be (in this case WebRequestEventRouter). This inconsistency might be problematic on its own but is resolved by enabling WebRequestPersistFilteredEventsViaEventRouter. It is a bit hard to fully simulate with webRequest because it is a race (needs to unregister an event listener while profile is marked as shutting down). This issue happened to us frequently because how our service worker is constructed, so this was my solution for it, which I think that should be the expected behavior anyway for callers that call any api that uses DispatchEventImpl with cannot_dispatch_callback even if the specific issue with WebRequestEventRouter won't exists soon.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
event_router()->DispatchEventToExtension(ext1, std::move(event));Andrea OrruUhm... If this case is not properly handling, do you know why [this test](https://crsrc.org/c/chrome/browser/extensions/api/web_request/web_request_apitest.cc;drc=2619b946b249d21cc1f2f1e08edcec3ecb8fdc4e;l=6927) is not failing?
Tal KerenOh I see. In the case you're covering, there's no lazy listener either...?
Yes, the case that I am covering is when webRequest doesn't have a listener or a lazy listener, but the caller of the API think that there might be (in this case WebRequestEventRouter). This inconsistency might be problematic on its own but is resolved by enabling WebRequestPersistFilteredEventsViaEventRouter. It is a bit hard to fully simulate with webRequest because it is a race (needs to unregister an event listener while profile is marked as shutting down). This issue happened to us frequently because how our service worker is constructed, so this was my solution for it, which I think that should be the expected behavior anyway for callers that call any api that uses DispatchEventImpl with cannot_dispatch_callback even if the specific issue with WebRequestEventRouter won't exists soon.
It will behave more like EventRouter::DispatchPendingEvent and will call cannot_dispatch_callback for any failure reason.
Reference the bug.
`Bug: 467448815, 484218883`
Acknowledged
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
Thank you Tal! This is a really good patch. Just a few comments.
cases where a dispatch is undeliverable for other reasons, such as whenCan you expand on what the reasons are? As far as I can tell:
WebRequestEventRouter was one manifestation of this problem.Can you explain the nature of the inconsistency?
undeliverable-dispatch fallback more robustPeriod at the end of the sentence.
event_router()->DispatchEventToExtension(ext1, std::move(event));Andrea OrruUhm... If this case is not properly handling, do you know why [this test](https://crsrc.org/c/chrome/browser/extensions/api/web_request/web_request_apitest.cc;drc=2619b946b249d21cc1f2f1e08edcec3ecb8fdc4e;l=6927) is not failing?
Tal KerenOh I see. In the case you're covering, there's no lazy listener either...?
Tal KerenYes, the case that I am covering is when webRequest doesn't have a listener or a lazy listener, but the caller of the API think that there might be (in this case WebRequestEventRouter). This inconsistency might be problematic on its own but is resolved by enabling WebRequestPersistFilteredEventsViaEventRouter. It is a bit hard to fully simulate with webRequest because it is a race (needs to unregister an event listener while profile is marked as shutting down). This issue happened to us frequently because how our service worker is constructed, so this was my solution for it, which I think that should be the expected behavior anyway for callers that call any api that uses DispatchEventImpl with cannot_dispatch_callback even if the specific issue with WebRequestEventRouter won't exists soon.
It will behave more like EventRouter::DispatchPendingEvent and will call cannot_dispatch_callback for any failure reason.
Acknowledged
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Moving Devlin to cc since he's traveling, adding Emilia.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
cases where a dispatch is undeliverable for other reasons, such as whenCan you expand on what the reasons are? As far as I can tell:
- Events with zero or blocked listeners are silently swallowed.
- During broadcasts, failures in one extension can incorrectly abort successful WebRequest blocking requests from another.
I have updated the message.
But about the second point - it is a good point, didn't think about it, but it is actually divergent from EventRouter::DispatchPendingEvent. With broadcast and cannot_dispatch_callback - if any context is inactive at time of dispatch, EventRouter::DispatchPendingEvent is not aware about other potential listeners.
so I don't think that this callback can work properly with broadcast anyway.
it also made me look up how this callback is documenteed:
// Called if the event cannot be dispatched to a lazy listener. This happens
// if e.g. the extension registers an event listener from a lazy context
// asynchronously, which results in the active listener not being registered
// at the time the lazy context is spun back up.
CannotDispatchCallback cannot_dispatch_callback;
I wonder if it should be updated in any way.
WebRequestEventRouter was one manifestation of this problem.Can you explain the nature of the inconsistency?
Done
Period at the end of the sentence.
Done
nit: newline above this return
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
cases where a dispatch is undeliverable for other reasons, such as whenTal KerenCan you expand on what the reasons are? As far as I can tell:
- Events with zero or blocked listeners are silently swallowed.
- During broadcasts, failures in one extension can incorrectly abort successful WebRequest blocking requests from another.
I have updated the message.
But about the second point - it is a good point, didn't think about it, but it is actually divergent from EventRouter::DispatchPendingEvent. With broadcast and cannot_dispatch_callback - if any context is inactive at time of dispatch, EventRouter::DispatchPendingEvent is not aware about other potential listeners.
so I don't think that this callback can work properly with broadcast anyway.it also made me look up how this callback is documenteed:
// Called if the event cannot be dispatched to a lazy listener. This happens
// if e.g. the extension registers an event listener from a lazy context
// asynchronously, which results in the active listener not being registered
// at the time the lazy context is spun back up.
CannotDispatchCallback cannot_dispatch_callback;
I wonder if it should be updated in any way.
I was talking about the scenario you are testing in the second unit test.
return false;nit: newline above this return
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
cases where a dispatch is undeliverable for other reasons, such as whenTal KerenCan you expand on what the reasons are? As far as I can tell:
- Events with zero or blocked listeners are silently swallowed.
- During broadcasts, failures in one extension can incorrectly abort successful WebRequest blocking requests from another.
Andrea OrruI have updated the message.
But about the second point - it is a good point, didn't think about it, but it is actually divergent from EventRouter::DispatchPendingEvent. With broadcast and cannot_dispatch_callback - if any context is inactive at time of dispatch, EventRouter::DispatchPendingEvent is not aware about other potential listeners.
so I don't think that this callback can work properly with broadcast anyway.it also made me look up how this callback is documenteed:
// Called if the event cannot be dispatched to a lazy listener. This happens
// if e.g. the extension registers an event listener from a lazy context
// asynchronously, which results in the active listener not being registered
// at the time the lazy context is spun back up.
CannotDispatchCallback cannot_dispatch_callback;
I wonder if it should be updated in any way.
I was talking about the scenario you are testing in the second unit test.
Oh, I thought about BroadastEvent for a moment, but the helper doesn't even have that functionality. so nvm.
About the second scenario, I think that "when all candidate listeners are filtered out by the target extension." should cover it.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
cases where a dispatch is undeliverable for other reasons, such as whenTal KerenCan you expand on what the reasons are? As far as I can tell:
- Events with zero or blocked listeners are silently swallowed.
- During broadcasts, failures in one extension can incorrectly abort successful WebRequest blocking requests from another.
Andrea OrruI have updated the message.
But about the second point - it is a good point, didn't think about it, but it is actually divergent from EventRouter::DispatchPendingEvent. With broadcast and cannot_dispatch_callback - if any context is inactive at time of dispatch, EventRouter::DispatchPendingEvent is not aware about other potential listeners.
so I don't think that this callback can work properly with broadcast anyway.it also made me look up how this callback is documenteed:
// Called if the event cannot be dispatched to a lazy listener. This happens
// if e.g. the extension registers an event listener from a lazy context
// asynchronously, which results in the active listener not being registered
// at the time the lazy context is spun back up.
CannotDispatchCallback cannot_dispatch_callback;
I wonder if it should be updated in any way.
Tal KerenI was talking about the scenario you are testing in the second unit test.
Oh, I thought about BroadastEvent for a moment, but the helper doesn't even have that functionality. so nvm.
About the second scenario, I think that "when all candidate listeners are filtered out by the target extension." should cover it.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
```
CannotDispatchCallback cannot_dispatch_callback;
```
As you mentioned would be good to list the reasons that we know when this is called in the documentation comment.
Everything else looks good to me.
| Code-Review | +1 |
Overall lgtm, thanks Tal! Leaving the open comments to Andrea
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
cases where a dispatch is undeliverable for other reasons, such as when| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |