From 0aa5de9d26cb8639a0a104321d855a9b18a9d842 Mon Sep 17 00:00:00 2001 From: Gurkan Date: Tue, 24 Oct 2023 16:55:18 +0200 Subject: [PATCH 1/4] change the tryPort to use hostname.local (for wsl to work) --- bin/index.mts | 3 ++- pnpm-lock.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/index.mts b/bin/index.mts index 2581ef27d..79e1b78b5 100755 --- a/bin/index.mts +++ b/bin/index.mts @@ -24,6 +24,7 @@ import { logBuildPlugin } from "../src/util.mjs"; import { sassPlugin } from "esbuild-sass-plugin"; import { fileURLToPath } from "url"; import { AddonType, getAddonFolder, isMonoRepo, selectAddon } from "./mono.mjs"; +import { hostname } from "os"; interface BaseArgs { watch?: boolean; @@ -70,7 +71,7 @@ let connectingPromise: Promise | undefined; * Try to connect to RPC on a specific port and handle the READY event as well as errors and close events */ function tryPort(port: number): Promise { - ws = new WebSocket(`ws://127.0.0.1:${port}/?v=1&client_id=REPLUGGED-${random()}`); + ws = new WebSocket(`ws://${hostname()}.local:${port}/?v=1&client_id=REPLUGGED-${random()}`); return new Promise((resolve, reject) => { let didFinish = false; ws?.on("message", (data) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d4ad3d15..30f407bba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true From 4859f39d5e16661bc591e204aa704d801cda7018 Mon Sep 17 00:00:00 2001 From: Gurkan Date: Tue, 24 Oct 2023 17:26:39 +0200 Subject: [PATCH 2/4] Revert "change the tryPort to use hostname.local (for wsl to work)" This reverts commit 0aa5de9d26cb8639a0a104321d855a9b18a9d842. --- bin/index.mts | 3 +-- pnpm-lock.yaml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/index.mts b/bin/index.mts index 79e1b78b5..2581ef27d 100755 --- a/bin/index.mts +++ b/bin/index.mts @@ -24,7 +24,6 @@ import { logBuildPlugin } from "../src/util.mjs"; import { sassPlugin } from "esbuild-sass-plugin"; import { fileURLToPath } from "url"; import { AddonType, getAddonFolder, isMonoRepo, selectAddon } from "./mono.mjs"; -import { hostname } from "os"; interface BaseArgs { watch?: boolean; @@ -71,7 +70,7 @@ let connectingPromise: Promise | undefined; * Try to connect to RPC on a specific port and handle the READY event as well as errors and close events */ function tryPort(port: number): Promise { - ws = new WebSocket(`ws://${hostname()}.local:${port}/?v=1&client_id=REPLUGGED-${random()}`); + ws = new WebSocket(`ws://127.0.0.1:${port}/?v=1&client_id=REPLUGGED-${random()}`); return new Promise((resolve, reject) => { let didFinish = false; ws?.on("message", (data) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 30f407bba..0d4ad3d15 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true From d3d715998801dabf0b8984128c852c7bbab53b56 Mon Sep 17 00:00:00 2001 From: Gurkan Date: Tue, 24 Oct 2023 17:27:16 +0200 Subject: [PATCH 3/4] add hostname.local for wsl --- bin/index.mts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/index.mts b/bin/index.mts index 2581ef27d..79e1b78b5 100755 --- a/bin/index.mts +++ b/bin/index.mts @@ -24,6 +24,7 @@ import { logBuildPlugin } from "../src/util.mjs"; import { sassPlugin } from "esbuild-sass-plugin"; import { fileURLToPath } from "url"; import { AddonType, getAddonFolder, isMonoRepo, selectAddon } from "./mono.mjs"; +import { hostname } from "os"; interface BaseArgs { watch?: boolean; @@ -70,7 +71,7 @@ let connectingPromise: Promise | undefined; * Try to connect to RPC on a specific port and handle the READY event as well as errors and close events */ function tryPort(port: number): Promise { - ws = new WebSocket(`ws://127.0.0.1:${port}/?v=1&client_id=REPLUGGED-${random()}`); + ws = new WebSocket(`ws://${hostname()}.local:${port}/?v=1&client_id=REPLUGGED-${random()}`); return new Promise((resolve, reject) => { let didFinish = false; ws?.on("message", (data) => { From 859d85f2af956eada1b90b1f718208f212ceebdd Mon Sep 17 00:00:00 2001 From: Gurkan Date: Tue, 24 Oct 2023 18:53:18 +0200 Subject: [PATCH 4/4] add check for mac (ofc mac has to break something lol) --- bin/index.mts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/index.mts b/bin/index.mts index 79e1b78b5..6370bc871 100755 --- a/bin/index.mts +++ b/bin/index.mts @@ -24,7 +24,7 @@ import { logBuildPlugin } from "../src/util.mjs"; import { sassPlugin } from "esbuild-sass-plugin"; import { fileURLToPath } from "url"; import { AddonType, getAddonFolder, isMonoRepo, selectAddon } from "./mono.mjs"; -import { hostname } from "os"; +import { hostname, platform } from "os"; interface BaseArgs { watch?: boolean; @@ -67,11 +67,19 @@ let ws: WebSocket | undefined; let failed = false; let connectingPromise: Promise | undefined; +function isMac(): boolean { + return platform() === "darwin"; +} + /** * Try to connect to RPC on a specific port and handle the READY event as well as errors and close events */ function tryPort(port: number): Promise { - ws = new WebSocket(`ws://${hostname()}.local:${port}/?v=1&client_id=REPLUGGED-${random()}`); + ws = new WebSocket( + `ws://${ + isMac() ? "localhost" : `${hostname()}.local` + }:${port}/?v=1&client_id=REPLUGGED-${random()}`, + ); return new Promise((resolve, reject) => { let didFinish = false; ws?.on("message", (data) => {