@@ -168,24 +168,24 @@ 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 ( ) ;
174-
175- let mut join_set = tasks. lock ( ) . await ;
176- 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- } ;
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+ } ;
189189
190190 let mut join_set = tasks. lock ( ) . await ;
191191 join_set. spawn ( async move {
@@ -412,8 +412,8 @@ mod tests {
412412 /// gracefully degrade to an empty body instead of failing outright.
413413 #[ tokio:: test]
414414 async fn test_end_invocation_oversized_payload_still_processes ( ) {
415- // Mirrors the fixed handle_end_invocation logic: split the request
416- // 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.
417417 async fn handler ( request : axum:: extract:: Request ) -> StatusCode {
418418 use axum:: extract:: FromRequest ;
419419
0 commit comments