diff options
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/polyfills/http.ts | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 609a046ac..52aac4cae 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1610,19 +1610,25 @@ export class ServerImpl extends EventEmitter { return; } this.#ac = ac; - this.#server = serve( - { - handler: handler as Deno.ServeHandler, - ...this.#addr, - signal: ac.signal, - // @ts-ignore Might be any without `--unstable` flag - onListen: ({ port }) => { - this.#addr!.port = port; - this.emit("listening"); + try { + this.#server = serve( + { + handler: handler as Deno.ServeHandler, + ...this.#addr, + signal: ac.signal, + // @ts-ignore Might be any without `--unstable` flag + onListen: ({ port }) => { + this.#addr!.port = port; + this.emit("listening"); + }, + ...this._additionalServeOptions?.(), }, - ...this._additionalServeOptions?.(), - }, - ); + ); + } catch (e) { + this.emit("error", e); + return; + } + if (this.#unref) { this.#server.unref(); } |