summaryrefslogtreecommitdiff
path: root/ext/http/00_serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/http/00_serve.js')
-rw-r--r--ext/http/00_serve.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/http/00_serve.js b/ext/http/00_serve.js
index 761c3219e..43b04ff28 100644
--- a/ext/http/00_serve.js
+++ b/ext/http/00_serve.js
@@ -427,7 +427,17 @@ async function asyncResponse(responseBodies, req, status, stream) {
responseRid = op_http_set_response_body_stream(req);
SetPrototypeAdd(responseBodies, responseRid);
op_http_set_promise_complete(req, status);
- timeoutPromise = core.writeAll(responseRid, value1);
+ // TODO(mmastrac): if this promise fails before we get to the await below, it crashes
+ // the process with an error:
+ //
+ // 'Uncaught (in promise) BadResource: failed to write'.
+ //
+ // To avoid this, we're going to swallow errors here and allow the code later in the
+ // file to re-throw them in a way that doesn't appear to be an uncaught promise rejection.
+ timeoutPromise = PromisePrototypeCatch(
+ core.writeAll(responseRid, value1),
+ () => null,
+ );
}, 250);
const { value: value2, done: done2 } = await reader.read();