From ac102d41e22b36cb8dd09cf79b7a53cb7de41ee6 Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Mon, 30 Sep 2024 16:29:59 +0800 Subject: [PATCH] fix: auto increase port number (#830) * fix: auto increase port number * bump --- executor/package.json | 2 +- packages/chopsticks/package.json | 2 +- packages/chopsticks/src/server.ts | 6 +++--- packages/core/package.json | 2 +- packages/db/package.json | 2 +- packages/testing/package.json | 2 +- packages/utils/package.json | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/executor/package.json b/executor/package.json index 8f1b2c70..e7ac0155 100644 --- a/executor/package.json +++ b/executor/package.json @@ -1,7 +1,7 @@ { "name": "@acala-network/chopsticks-executor", "description": "Chopsticks executor", - "version": "0.16.0", + "version": "0.16.1", "license": "Apache-2.0", "type": "module", "repository": { diff --git a/packages/chopsticks/package.json b/packages/chopsticks/package.json index 4462a9c7..afbf0f16 100644 --- a/packages/chopsticks/package.json +++ b/packages/chopsticks/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks", - "version": "0.16.0", + "version": "0.16.1", "author": "Acala Developers ", "license": "Apache-2.0", "bin": "./chopsticks.cjs", diff --git a/packages/chopsticks/src/server.ts b/packages/chopsticks/src/server.ts index bbe4e579..efc03fb1 100644 --- a/packages/chopsticks/src/server.ts +++ b/packages/chopsticks/src/server.ts @@ -57,7 +57,7 @@ const respond = (res: http.ServerResponse, data?: any) => { res.end() } -const portInUse = async (port: number) => { +const portInUse = async (port: number, addr: string) => { const server = http.createServer() const inUse = await new Promise((resolve) => { server.once('error', (e: any) => { @@ -71,7 +71,7 @@ const portInUse = async (port: number) => { server.close() resolve(false) }) - server.listen(port) + server.listen(port, addr) }) server.removeAllListeners() server.unref() @@ -151,7 +151,7 @@ export const createServer = async (handler: Handler, addr: string, port: number) }) for (let i = 0; i < 10; i++) { - if (port && (await portInUse(port + i))) { + if (port && (await portInUse(port + i, addr))) { continue } const preferPort = port ? port + i : undefined diff --git a/packages/core/package.json b/packages/core/package.json index f8f8bbb8..24c8ca11 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-core", - "version": "0.16.0", + "version": "0.16.1", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", diff --git a/packages/db/package.json b/packages/db/package.json index 660e7fcc..45775215 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-db", - "version": "0.16.0", + "version": "0.16.1", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", diff --git a/packages/testing/package.json b/packages/testing/package.json index 6b262e0c..e7cc565c 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-testing", - "version": "0.16.0", + "version": "0.16.1", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", diff --git a/packages/utils/package.json b/packages/utils/package.json index 69f72b60..dc40bc36 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-utils", - "version": "0.16.0", + "version": "0.16.1", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module",