diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 306dd2c220ffd6a1e5aeaf7add428f1700c70942..92657d629a4b9c8fa02bc0e4801295e66a49cb3f 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -30,6 +30,7 @@ rules: eqeqeq: error import/order: [error, { alphabetize: { order: "asc" }, groups: [["builtin", "external", "internal"], "parent", "sibling"] }] + no-async-promise-executor: off settings: # Does not work with CommonJS unfortunately. diff --git a/src/node/http.ts b/src/node/http.ts index 297dda0cce1af55612d1e3f719d318f3e96b1ef6..c616c88377b885755bfb6f896a3ed612528c8738 100644 --- a/src/node/http.ts +++ b/src/node/http.ts @@ -578,11 +578,18 @@ export class HttpServer { */ public listen(): Promise { if (!this.listenPromise) { - this.listenPromise = new Promise((resolve, reject) => { + this.listenPromise = new Promise(async (resolve, reject) => { this.server.on("error", reject) this.server.on("upgrade", this.onUpgrade) const onListen = (): void => resolve(this.address()) if (this.options.socket) { + try { + await fs.unlink(this.options.socket) + } catch (err) { + if (err.code !== "ENOENT") { + logger.warn(err.message) + } + } this.server.listen(this.options.socket, onListen) } else if (this.options.host) { // [] is the correct format when using :: but Node errors with them.