Handling response headers/trailers in ConnectionCallbacks::OnEvent(Remote/LocalClose) vs Dtor of network filter
Title: Handling response headers/trailers in ConnectionCallbacks::OnEvent(Remote/LocalClose) vs Dtor of network filter
Description: I'm trying to understand which operations happen between ConnectionCallbacks::OnEvent(ConnectionEvent::RemoteClose/LocalClose) and the destructor of network filters being called, I mean can I assume that the destruction of network filters is done immediately after OnEvent finish, or some operations happen in between, and if so which kind of operations can happen?
More context about my question: I'm using "TCP tunneling over HTTP" feature in TcpProxy filter with the following two options: propagate_response_headers & propagate_response_trailers and I want to read headers/trailers from FilterState at the end of the connection. Should I handle response headers/trailers in OnEvent callback (assuming they will not be received in any way after that) or should I wait in that to the destructor of network filter?
I've tried to understand what happens when envoy gets a reset from downstream -> ConnectionImpl::onFileEvent is called which includes a call for ConnectionCallbacks::OnEvent and adding items to deferred deletion list, then DispatcherImpl::deferredDelete is called which incluses destruction of network filters, but I'm not sure if in some situations can something happen between ConnectionImpl::onFileEvent and DispatcherImpl::deferredDelete?
deferredDelete posts the delete to the event loop, so if the event loop is busy some other event processing could happen between the onEvent and Dtor.
@lizan So handling response headers/trailers in onEvent can cause a loss of headers/trailers in some cases as they can be received after onEvent being called?
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.