summaryrefslogtreecommitdiff
path: root/ext/flash/lib.rs
diff options
context:
space:
mode:
authorIsaiah Gamble <77396670+tsar-boomba@users.noreply.github.com>2023-01-14 23:59:35 -0500
committerGitHub <noreply@github.com>2023-01-15 04:59:35 +0000
commit9830ae82974878da8c4c4dbb34bf3a2076a82547 (patch)
treeb339674589bc24ec5404a564ce8f0e8c05523843 /ext/flash/lib.rs
parent2f15efbb3d468ea8c2be31c21f7df80c4f9ba368 (diff)
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.
Diffstat (limited to 'ext/flash/lib.rs')
-rw-r--r--ext/flash/lib.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs
index a37a43641..7a7849be1 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 =