diff --git a/lambda-runtime/src/streaming.rs b/lambda-runtime/src/streaming.rs index 85af784e..15cd210f 100644 --- a/lambda-runtime/src/streaming.rs +++ b/lambda-runtime/src/streaming.rs @@ -108,6 +108,14 @@ where let event = next_event_response?; let (parts, body) = event.into_parts(); + #[cfg(debug_assertions)] + if parts.status == http::StatusCode::NO_CONTENT { + // Ignore the event if the status code is 204. + // This is a way to keep the runtime alive when + // there are no events pending to be processed. + continue; + } + let ctx: Context = Context::try_from(parts.headers)?; let ctx: Context = ctx.with_config(config); let request_id = &ctx.request_id.clone(); @@ -128,6 +136,12 @@ where let body = hyper::body::to_bytes(body).await?; trace!("incoming request payload - {}", std::str::from_utf8(&body)?); + #[cfg(debug_assertions)] + if parts.status.is_server_error() { + error!("Lambda Runtime server returned an unexpected error"); + return Err(parts.status.to_string().into()); + } + let body = match serde_json::from_slice(&body) { Ok(body) => body, Err(err) => {