-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Use a fresh execution context for application logic #46164
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
src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs
Show resolved
Hide resolved
It's a fairly aggressive change but does make sense to avoid the strangeness that It will definitely break some apps, though hopefully not many. For such people, what's your opinion about having a compat flag to opt back into the old and unsupported behavior? I did a bit of searching for evidence about how widespread the breakage is likely to be, and:
I guess the biggest issue would be if it turns out that some widely-used open-source or component-vendor component is using this, and hence it breaks apps that don't even have the power to change the component implementation. But it seems fairly unlikely since, at the very least, any such component would already not support WebAssembly, and would have to tell people to call A further point in favor is that this is going in an early preview release, not in some RC or patch, giving plenty of opportunity to change course later if needed. So altogether I'm comfortable with the breaking change. We'd still need to make the announcement and write up the steps to work around it (e.g., if people were doing this to access some cookie data, they should read it in |
What impact does this have on default tracing behavior? Does it mean that things that were traced before are no longer traced, or they are just grouped differently? Is the new default better than the old one? |
@davidfowl I concur with what @SteveSandersonMS has said here. I am also supportive of this change, and I think it is best if we do it early to give libraries time to adapt if needed. I think we should think about what uses people typically have for HttpContext within Blazor apps and see if we can smooth out the pattern to deal with those. I do not think we have concrete docs about how to do this properly, outside a comment about how to do it for passing the auth tokens to the circuit in Blazor Server apps. I'm also in favor if we want to have a compat switch to avoid surprises, but with the idea that it will last for a single release. As for the tracing, we should ensure we do the work to produce the right experience for Blazor apps. |
It’s breaking the blazor server tests that verify the current culture flows as well. That will definitely break some people. the other option is to try to make the things that are broken “work. So potentially resetting the activity, and updating the http context accessor appropriately. |
@davidfowl did you have a proposal for how to preserve the culture from the original request? That seems important. Does it need a new Blazor abstraction to enable flowing it from the host (similar to |
// Preserve the connection id logging scope when we execute the connection delegate | ||
var logScope = new ConnectionLogScope(ConnectionId); | ||
|
||
// REVIEW: Should we create also create an activity 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 guess you meant Should we also create an activity here
Discard the execution context when running the user application in the http transport. This stops all async locals from flowing from the initial request that establishes the SignalR connection from flowing into the connection delegate pipeline.
"Fixes" #29846. Blazor server will no longer get an activity.
cc @javiercn @SteveSandersonMS