Skip to content

Commit

Permalink
fix(cli): handle consecutive npx install race condition (#4643)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Sep 14, 2024
1 parent acb1e58 commit d73bf9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/cli/cli/src/rerunFernCliAtVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ export async function rerunFernCliAtVersion({
].join("\n")
);

const { failed } = await loggingExeca(cliContext.logger, "npx", ["--quiet", ...commandLineArgs], {
const { failed, stdout, stderr } = await loggingExeca(cliContext.logger, "npx", ["--quiet", ...commandLineArgs], {
stdio: "inherit",
reject: false,
env: {
...env,
[FERN_CWD_ENV_VAR]: process.env[FERN_CWD_ENV_VAR] ?? process.cwd()
}
});
if (stdout.includes("code EEXIST") || stderr.includes("code EEXIST")) {
// try again if there is a npx conflict
return await rerunFernCliAtVersion({
version,
cliContext
});
}

if (failed) {
cliContext.failWithoutThrowing();
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
- changelogEntry:
- summary: |
The Fern CLI now safely handles a npx file exists error by retrying the command on failure.
This error typically happens when two or more instances of the Fern CLI are running `npx`
at the same time.
type: fix
irVersion: 53
version: 0.41.14-rc0

- changelogEntry:
- summary: |
`fern generate --local` no longer crashes on large API Definitions because we
Expand Down

0 comments on commit d73bf9c

Please sign in to comment.