Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change the tryPort to use hostname.local (for wsl to work) #582

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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, platform } from "os";

interface BaseArgs {
watch?: boolean;
Expand Down Expand Up @@ -66,11 +67,19 @@ let ws: WebSocket | undefined;
let failed = false;
let connectingPromise: Promise<WebSocket | undefined> | 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<WebSocket | undefined> {
ws = new WebSocket(`ws://127.0.0.1:${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) => {
Expand Down
Loading