summaryrefslogtreecommitdiff
path: root/std/http
diff options
context:
space:
mode:
Diffstat (limited to 'std/http')
-rw-r--r--std/http/server.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/std/http/server.ts b/std/http/server.ts
index 6e26e8456..d7ed60c53 100644
--- a/std/http/server.ts
+++ b/std/http/server.ts
@@ -198,9 +198,15 @@ export class Server implements AsyncIterable<ServerRequest> {
): AsyncIterableIterator<ServerRequest> {
if (this.closing) return;
// Wait for a new connection.
- const { value, done } = await this.listener.next();
- if (done) return;
- const conn = value as Conn;
+ let conn: Conn;
+ try {
+ conn = await this.listener.accept();
+ } catch (error) {
+ if (error instanceof Deno.errors.BadResource) {
+ return;
+ }
+ throw error;
+ }
// Try to accept another connection and add it to the multiplexer.
mux.add(this.acceptConnAndIterateHttpRequests(mux));
// Yield the requests that arrive on the just-accepted connection.