Description
Currently, if a plugin initiated an outbound gRPC or HTTP call, the response to that call is dispatched in a callback for which the effective context is the root context rather than the initiating stream context. This means that if callout response callback code attempts to perform an operation that is dependent on a stream context, such as sendLocalResponse
(see envoyproxy/envoy#39797), that operation will fail.
We should either:
A. Change the default behavior of HTTP / gRPC response callbacks to set the initiating stream context as the effective context, or
B. Clearly document the current behavior, and suggest that plugins call Context::setEffectiveContext() if they want to reassert the stream context in the response callback.
(A) is a behavior change, so comes with some risk of breaking plugins that depend on the current behavior. Per Chesterton's fence, it would also be good to understand better the existing choice of default before changing it. @kyessenov suggested this might be because one of the initial uses of gRPC callouts (for telemetry export) wanted to batch data across streams. @PiotrSikora do you remember any other considerations?