Skip to content

Commit

Permalink
fix: correctly handle null body statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
laktek committed May 18, 2023
1 parent 006b9b0 commit 9de4c6e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/sb_workers/user_workers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const ops = core.ops;

const chunkExpression = /(?:^|\W)chunked(?:$|\W)/i;

function nullBodyStatus(status) {
return status === 101 || status === 204 || status === 205 || status === 304;
}

class UserWorker {
constructor(key) {
this.key = key;
Expand Down Expand Up @@ -49,7 +53,7 @@ class UserWorker {

const res = await core.opAsync("op_user_worker_fetch_send", this.key, requestRid);
const bodyStream = readableStreamForRid(res.bodyRid);
return new Response(bodyStream, {
return new Response(nullBodyStatus(res.status) ? null : bodyStream, {
headers: res.headers,
status: res.status,
statusText: res.statusText
Expand Down

0 comments on commit 9de4c6e

Please sign in to comment.