Skip to content

Commit 1e15ecb

Browse files
committed
solving merge conflict
1 parent 6530cbc commit 1e15ecb

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

bottlecap/src/lifecycle/listener.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,25 +168,27 @@ impl Listener {
168168
State((invocation_processor_handle, _, tasks)): State<ListenerState>,
169169
request: Request,
170170
) -> Response {
171-
// Split the request upfront so headers are preserved even if body
172-
// extraction fails (e.g. oversized MSK payloads exceeding 6MB).
171+
// IMPORTANT: Extract the body synchronously before returning the response.
172+
// If this is moved into the spawned task, PlatformRuntimeDone may be
173+
// processed before the body is read, causing orphaned traces. (SLES-2666)
174+
// On oversized payloads (>6MB) we gracefully degrade to an empty body
175+
// so that processing still runs. (SLES-2722)
173176
let (parts, body) = request.into_parts();
177+
let body = match Bytes::from_request(
178+
axum::extract::Request::from_parts(parts.clone(), body),
179+
&(),
180+
)
181+
.await
182+
{
183+
Ok(b) => b,
184+
Err(e) => {
185+
warn!("Failed to buffer end-invocation request body: {e}. Processing with empty payload.");
186+
Bytes::new()
187+
}
188+
};
174189

175190
let mut join_set = tasks.lock().await;
176191
join_set.spawn(async move {
177-
let body = match Bytes::from_request(
178-
axum::extract::Request::from_parts(parts.clone(), body),
179-
&(),
180-
)
181-
.await
182-
{
183-
Ok(b) => b,
184-
Err(e) => {
185-
warn!("Failed to buffer end-invocation request body: {e}. Processing with empty payload.");
186-
Bytes::new()
187-
}
188-
};
189-
190192
Self::universal_instrumentation_end(&parts.headers, body, invocation_processor_handle)
191193
.await;
192194
});
@@ -410,8 +412,8 @@ mod tests {
410412
/// gracefully degrade to an empty body instead of failing outright.
411413
#[tokio::test]
412414
async fn test_end_invocation_oversized_payload_still_processes() {
413-
// Mirrors the fixed handle_end_invocation logic: split the request
414-
// upfront, attempt body extraction, fall back to empty bytes.
415+
// Mirrors the fixed handle_end_invocation logic: synchronously attempt
416+
// body extraction before spawning the task, fall back to empty bytes.
415417
async fn handler(request: axum::extract::Request) -> StatusCode {
416418
use axum::extract::FromRequest;
417419

0 commit comments

Comments
 (0)