From 11c6208fe2580d58a2e46f139ae99857418e87db Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 3 Mar 2021 01:12:18 +0100 Subject: [PATCH] core-api: workaround for backend:dev port conflict issue Signed-off-by: Patrik Oldsberg --- .changeset/perfect-scissors-swim.md | 5 +++++ packages/cli/src/commands/backend/dev.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/perfect-scissors-swim.md diff --git a/.changeset/perfect-scissors-swim.md b/.changeset/perfect-scissors-swim.md new file mode 100644 index 0000000000..7cbe02d321 --- /dev/null +++ b/.changeset/perfect-scissors-swim.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Fixed an issue where the `backend:dev` command would get stuck executing the backend process multiple times, causing port conflict issues. diff --git a/packages/cli/src/commands/backend/dev.ts b/packages/cli/src/commands/backend/dev.ts index 88c069a92b..395fe8a4ab 100644 --- a/packages/cli/src/commands/backend/dev.ts +++ b/packages/cli/src/commands/backend/dev.ts @@ -14,10 +14,17 @@ * limitations under the License. */ +import fs from 'fs-extra'; import { Command } from 'commander'; +import { paths } from '../../lib/paths'; import { serveBackend } from '../../lib/bundler/backend'; export default async (cmd: Command) => { + // Cleaning dist/ before we start the dev process helps work around an issue + // where we end up with the entrypoint executing multiple times, causing + // a port bind conflict among other things. + await fs.remove(paths.resolveTarget('dist')); + const waitForExit = await serveBackend({ entry: 'src/index', checksEnabled: cmd.check,