summaryrefslogtreecommitdiff
path: root/http/server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'http/server.ts')
-rw-r--r--http/server.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/http/server.ts b/http/server.ts
index 265dde943..54ec397d3 100644
--- a/http/server.ts
+++ b/http/server.ts
@@ -342,10 +342,15 @@ export class Server implements AsyncIterable<ServerRequest> {
// The connection was gracefully closed.
} else if (err) {
// An error was thrown while parsing request headers.
- await writeResponse(req!.w, {
- status: 400,
- body: new TextEncoder().encode(`${err.message}\r\n\r\n`)
- });
+ try {
+ await writeResponse(req!.w, {
+ status: 400,
+ body: new TextEncoder().encode(`${err.message}\r\n\r\n`)
+ });
+ } catch (_) {
+ // The connection is destroyed.
+ // Ignores the error.
+ }
} else if (this.closing) {
// There are more requests incoming but the server is closing.
// TODO(ry): send a back a HTTP 503 Service Unavailable status.