diff --git a/messages/webapp.dev.md b/messages/webapp.dev.md index 2ba040f..5d8f6a0 100644 --- a/messages/webapp.dev.md +++ b/messages/webapp.dev.md @@ -176,6 +176,11 @@ Failed to watch manifest: %s Dev server unreachable at %s. Start your dev server manually at that URL, or add dev.command to webapplication.json to start it automatically. +# error.dev-url-unreachable-with-flag + +Dev server unreachable at %s. +Remove --url to use dev.command to start the server automatically, or ensure your dev server is running at that URL. + # error.port-in-use Port %s is already in use. Try specifying a different port with the --port flag or stopping the service that's using the port. diff --git a/src/commands/webapp/dev.ts b/src/commands/webapp/dev.ts index b7d7631..61ec49e 100644 --- a/src/commands/webapp/dev.ts +++ b/src/commands/webapp/dev.ts @@ -288,8 +288,15 @@ export default class WebappDev extends SfCommand { devServerUrl = resolvedUrl; this.log(messages.getMessage('info.url-already-available', [resolvedUrl])); this.logger.debug(`URL ${resolvedUrl} is reachable, skipping dev server startup`); - } else if ((flags.url ?? manifest?.dev?.url) && !manifest?.dev?.command?.trim()) { - // Explicit URL (--url or dev.url) but no dev.command - don't start (we can't control the port) + } else if (flags.url) { + // User explicitly passed --url; assume server is already running at that URL + // Fail immediately if unreachable (don't start dev server) + throw new SfError(messages.getMessage('error.dev-url-unreachable-with-flag', [resolvedUrl]), 'DevServerUrlError', [ + `Ensure your dev server is running at ${resolvedUrl}`, + 'Remove --url to use dev.command to start the server automatically', + ]); + } else if (manifest?.dev?.url && !manifest?.dev?.command?.trim()) { + // dev.url in manifest but no dev.command - don't start (we can't control the port) throw new SfError(messages.getMessage('error.dev-url-unreachable', [resolvedUrl]), 'DevServerUrlError', [ `Ensure your dev server is running at ${resolvedUrl}`, 'Or add dev.command to webapplication.json to start it automatically',