Skip to content

Commit 8c620ec

Browse files
sshaderConvex, Inc.
authored andcommitted
[cli] Print nicer message if local dashboard is not running (#35890)
GitOrigin-RevId: 2d195213f74a09af7ae7a5a0262d2cedfe650bc8
1 parent 7e32d58 commit 8c620ec

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

npm-packages/convex/src/cli/dashboard.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import { actionDescription } from "./lib/command.js";
1616
import { getDeploymentSelection } from "./lib/deploymentSelection.js";
1717
import { isTryItOutDeployment } from "./lib/deployment.js";
1818
import { loadDashboardConfig } from "./lib/localDeployment/filePaths.js";
19-
import { DEFAULT_LOCAL_DASHBOARD_API_PORT } from "./lib/localDeployment/dashboard.js";
19+
import {
20+
DEFAULT_LOCAL_DASHBOARD_API_PORT,
21+
checkIfDashboardIsRunning,
22+
} from "./lib/localDeployment/dashboard.js";
2023
const DASHBOARD_HOST = process.env.CONVEX_PROVISION_HOST
2124
? "http://localhost:6789"
2225
: "https://dashboard.convex.dev";
@@ -55,17 +58,18 @@ export const dashboard = new Command("dashboard")
5558
logWarning(ctx, warningMessage);
5659
return;
5760
}
61+
const isLocalDashboardRunning =
62+
await checkIfDashboardIsRunning(dashboardConfig);
63+
if (!isLocalDashboardRunning) {
64+
logWarning(ctx, warningMessage);
65+
return;
66+
}
5867

5968
const queryString =
6069
dashboardConfig.apiPort !== DEFAULT_LOCAL_DASHBOARD_API_PORT
6170
? `?apiPort=${dashboardConfig.apiPort}`
6271
: "";
6372
const dashboardUrl = `http://127.0.0.1:${dashboardConfig.port}${queryString}`;
64-
const response = await fetch(dashboardUrl);
65-
if (!response.ok) {
66-
logWarning(ctx, warningMessage);
67-
return;
68-
}
6973
await logOrOpenUrl(ctx, dashboardUrl, options.open);
7074
return;
7175
}

npm-packages/convex/src/cli/lib/localDeployment/dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async function startServingListDeploymentsApi(ctx: Context, port: number) {
7979
);
8080
}
8181

82-
async function checkIfDashboardIsRunning(config: DashboardConfig) {
82+
export async function checkIfDashboardIsRunning(config: DashboardConfig) {
8383
// We're checking if the mini API server is running and has a response that
8484
// looks like a list of deployments, since it's easier than checking the
8585
// dashboard UI.

0 commit comments

Comments
 (0)