Skip to content

Commit

Permalink
Revert "Report correct IP & port in local mode (#3337)" (#3557)
Browse files Browse the repository at this point in the history
This reverts commit 9ced24c.
  • Loading branch information
penalosa authored Jul 5, 2023
1 parent 4ac684b commit 78bc079
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 0 additions & 7 deletions .changeset/slow-beans-wink.md

This file was deleted.

7 changes: 6 additions & 1 deletion packages/wrangler/src/dev/remote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function Remote(props: RemoteProps) {
zone: props.zone,
host: props.host,
routes: props.routes,
onReady: props.onReady,
sendMetrics: props.sendMetrics,
port: props.port,
});
Expand All @@ -95,7 +96,6 @@ export function Remote(props: RemoteProps) {
localProtocol: props.localProtocol,
localPort: props.port,
ip: props.ip,
onReady: props.onReady,
});

useInspector({
Expand Down Expand Up @@ -172,6 +172,7 @@ interface RemoteWorkerProps {
zone: string | undefined;
host: string | undefined;
routes: Route[] | undefined;
onReady: ((ip: string, port: number) => void) | undefined;
sendMetrics: boolean | undefined;
port: number;
}
Expand All @@ -186,6 +187,8 @@ export function useWorker(
// something's "happened" in our system; We make a ref and
// mark it once we log our initial message. Refs are vars!
const startedRef = useRef(false);
// functions must be destructured before use inside a useEffect, otherwise the entire props object has to be added to the dependency array
const { onReady } = props;
// This effect sets up the preview session
useEffect(() => {
const abortController = new AbortController();
Expand Down Expand Up @@ -320,6 +323,7 @@ export function useWorker(
});
}
*/
onReady?.(props.host || "localhost", props.port);
}
start().catch((err) => {
// we want to log the error, but not end the process
Expand Down Expand Up @@ -371,6 +375,7 @@ export function useWorker(
props.host,
props.routes,
session,
onReady,
props.sendMetrics,
props.port,
]);
Expand Down
5 changes: 1 addition & 4 deletions packages/wrangler/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,12 @@ export function usePreviewServer({
localProtocol,
localPort: port,
ip,
onReady,
}: {
previewToken: CfPreviewToken | undefined;
assetDirectory: string | undefined;
localProtocol: "https" | "http";
localPort: number;
ip: string;
onReady: ((finalIp: string, finalPort: number) => void) | undefined;
}) {
/** Creates an HTTP/1 proxy that sends requests over HTTP/2. */
const [proxy, setProxy] = useState<PreviewProxy>();
Expand Down Expand Up @@ -301,7 +299,6 @@ export function usePreviewServer({
const usedPort =
address && typeof address === "object" ? address.port : port;
logger.log(`⬣ Listening at ${localProtocol}://${ip}:${usedPort}`);
onReady?.(ip, usedPort);
const accessibleHosts =
ip !== "0.0.0.0" ? [ip] : getAccessibleHosts();
for (const accessibleHost of accessibleHosts) {
Expand All @@ -324,7 +321,7 @@ export function usePreviewServer({
.terminate()
.catch(() => logger.error("Failed to terminate the proxy server."));
};
}, [port, ip, proxy, localProtocol, onReady]);
}, [port, ip, proxy, localProtocol]);
}

function configureProxyServer({
Expand Down

0 comments on commit 78bc079

Please sign in to comment.