From 2df72a6e545ce2f13ac3c9c67d5d02e513802372 Mon Sep 17 00:00:00 2001 From: Isaiah Gamble <77396670+tsar-boomba@users.noreply.github.com> Date: Sat, 14 Jan 2023 23:59:35 -0500 Subject: [PATCH] fix(ext/flash): Fix panic when JS caller doesn't consume request body (#16173) If the JS handler gets a POST, PUT, or PATCH request, but doesn't `await` the body, deno would panic because it will try to read the body even though the request has already been handled. Not sure how/where to test this case, so I could use some help with that. --- ext/flash/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs index a37a436411..7a7849be1d 100644 --- a/ext/flash/lib.rs +++ b/ext/flash/lib.rs @@ -754,7 +754,11 @@ async fn op_flash_read_body( .as_mut() .unwrap() }; - let tx = ctx.requests.get_mut(&token).unwrap(); + let tx = match ctx.requests.get_mut(&token) { + Some(tx) => tx, + // request was already consumed by caller + None => return 0, + }; if tx.te_chunked { let mut decoder =