Skip to content

Commit

Permalink
fix(ext/flash): Fix panic when JS caller doesn't consume request body (
Browse files Browse the repository at this point in the history
…denoland#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.
  • Loading branch information
tsar-boomba committed Jan 15, 2023
1 parent 2f15efb commit 9830ae8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ext/flash/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 9830ae8

Please sign in to comment.