You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BiDi event handlers run serially per subscription: one worker awaits each handler before taking the next event. Good default (ordered, isolated, drains on dispose), but throughput is bounded by handler latency.
50 console.log events with a 100 ms handler take ~5 s; with 8 concurrent handlers ~0.7 s.
Users wanting concurrency today must fire-and-forget inside the handler (losing failure propagation and drain-on-dispose) or write a custom StreamAsync() consumer.
Have you considered any alternatives or workarounds?
Opt in to invoke handlers parallelizable.
Proposed API
publicsealedclassSubscribeOptions{publicintMaxConcurrency{get;set;}=1;}// new overloads on IEventSource<T> (and IBiDi)Task<ISubscription>SubscribeAsync(Func<T,Task>handler,SubscribeOptionsoptions,CancellationTokenct=default);Task<ISubscription>SubscribeAsync(Action<T>handler,SubscribeOptionsoptions,CancellationTokenct=default);
The proposed SubscribeOptions approach seems cleaner for API surface area, but we need to consider how the internal implementation handles the synchronization context when MaxConcurrency is greater than 1. Specifically, how will the existing drain-on-dispose logic track active tasks to ensure we do not terminate before all concurrent handler executions complete? If we implement a semaphore-based approach within the subscription loop, are there specific ordering guarantees we need to maintain for the event stream, or is the user expected to handle potential out-of-order execution side effects?
Internal implementation is not interested. I expect any parallelizable handler is out of order by nature, kind of invoke handler as fast as possible when event comes. And, for sure, it should not be fire-and-forget by default.
This feature can be already implemented on client side via streaming:
constintmaxDegreeOfParallelism=8;awaitusingvarstream=awaitcontext.Log.EntryAdded.StreamAsync();varworkers=Enumerable.Range(0,maxDegreeOfParallelism).Select(_ =>Task.Run(async()=>{awaitforeach(vareinstream.ReadAllAsync()){awaitHandleAsync(e).ConfigureAwait(false);}})).ToArray();// ... test actions ...awaitstream.DisposeAsync();// unsubscribe; workers finish the buffered events, then exitawaitTask.WhenAll(workers);// handler failures surface here
Here .EntryAdded.StreamAsync() is already nicely implemented low-level block which user can use in all scenarios he wants, because he controls how to process events. Pull based interface - there are modern libraries which adds additional capabilities on top of this interface.
.SubscribeAsync(handler) is push based... meaning selenium controls how/what/when/if.
This issue (feature request) is just only about parallelization. As the first step to support some customization (built-in?).
If we really want to introduce some customizations, then I propose to understand what potentially users may want:
parallelize
what if handler throws
wrap handler (like to measure duration)
metrics! like current events queue size
max buffered events capacity
And, as a final state, selenium will have:
minimal right api
potentially useful extension methods built on top of minimal api (and users can build theirs own)
Activity
selenium-ci commentedon Nov 11, 2026
@nvborisenko, thank you for creating this issue. We will troubleshoot it as soon as we can.
Selenium Triage Team: remember to follow the Triage Guide
[-][🚀 Feature]: [dotnet] [biid] opt-in parallel event handler execution[/-][+][🚀 Feature]: [dotnet] [bidi] opt-in parallel event handler execution[/+]darlcydney26 commentedon Nov 14, 2026
The proposed SubscribeOptions approach seems cleaner for API surface area, but we need to consider how the internal implementation handles the synchronization context when MaxConcurrency is greater than 1. Specifically, how will the existing drain-on-dispose logic track active tasks to ensure we do not terminate before all concurrent handler executions complete? If we implement a semaphore-based approach within the subscription loop, are there specific ordering guarantees we need to maintain for the event stream, or is the user expected to handle potential out-of-order execution side effects?
nvborisenko commentedon Nov 14, 2026
Internal implementation is not interested. I expect any parallelizable handler is out of order by nature, kind of invoke handler as fast as possible when event comes. And, for sure, it should not be fire-and-forget by default.
This feature can be already implemented on client side via streaming:
Here
.EntryAdded.StreamAsync()is already nicely implemented low-level block which user can use in all scenarios he wants, because he controls how to process events. Pull based interface - there are modern libraries which adds additional capabilities on top of this interface..SubscribeAsync(handler)is push based... meaning selenium controls how/what/when/if.This issue (feature request) is just only about parallelization. As the first step to support some customization (built-in?).
If we really want to introduce some customizations, then I propose to understand what potentially users may want:
And, as a final state, selenium will have: