From bb2179a8cb9c193cd1496ede25b04042fce2bcaa Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 15 Dec 2021 23:55:32 -0500 Subject: [PATCH] Fix port collision caused by race condition in tests (#164) * Fix port collision caused by race condition in tests The ipv6 port is not randomized, if the previous ports for the last test didn't get freed in time, the server can crash on launch * try again * Update index.d.ts * Update genPacketDumps.js --- index.d.ts | 2 ++ tools/genPacketDumps.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index fe15ac4..5b0c8c2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,6 +24,8 @@ declare module "bedrock-protocol" { } export interface ClientOptions extends Options { + // The username to connect to the server as + username: string, // The view distance in chunks viewDistance?: number, // Specifies which game edition to sign in as. Optional, but some servers verify this. diff --git a/tools/genPacketDumps.js b/tools/genPacketDumps.js index a6741ea..4176b65 100644 --- a/tools/genPacketDumps.js +++ b/tools/genPacketDumps.js @@ -18,11 +18,11 @@ function hasDumps (version) { let loop async function dump (version, force = true) { - const random = ((Math.random() * 100) | 0) - const port = 19130 + random + const random = (Math.random() * 1000) | 0 + const [port, v6] = [19132 + random, 19133 + random] console.log('Starting dump server', version) - const handle = await vanillaServer.startServerAndWait(version || CURRENT_VERSION, 1000 * 120, { 'server-port': port }) + const handle = await vanillaServer.startServerAndWait(version || CURRENT_VERSION, 1000 * 120, { 'server-port': port, 'server-portv6': v6 }) console.log('Started dump server', version) const client = new Client({