Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/fix-ci-command-hanging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"lingo.dev": patch
---

Fix CI command hanging due to process.exit calls

- Remove PostHog shutdown() call that was causing process to hang
- Replace process.exit() with proper exception throwing in i18n and run commands
- Upgrade posthog-node from 5.5.1 to 5.8.1 for better stability
- This fixes the CI command integration where process.exit() was terminating the parent process instead of returning control
1 change: 0 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
</a>
</p>


---

## Meet the Compiler 🆕
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"p-limit": "^6.2.0",
"php-array-reader": "^2.1.2",
"plist": "^3.1.0",
"posthog-node": "^5.5.1",
"posthog-node": "^5.8.1",
"prettier": "^3.4.2",
"react": "^18.3.1",
"rehype-stringify": "^10.0.1",
Expand Down
19 changes: 10 additions & 9 deletions packages/cli/src/cli/cmd/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import createProcessor from "../processor";
import { withExponentialBackoff } from "../utils/exp-backoff";
import trackEvent from "../utils/observability";
import { createDeltaProcessor } from "../utils/delta";
import { exitGracefully } from "../utils/exit-gracefully";

export default new Command()
.command("i18n")
Expand Down Expand Up @@ -117,7 +116,7 @@ export default new Command()
ora.succeed(`Authenticated as ${auth.email}`);
}

trackEvent(authId, "cmd.i18n.start", {
await trackEvent(authId, "cmd.i18n.start", {
i18nConfig,
flags,
});
Expand All @@ -143,7 +142,9 @@ export default new Command()
ora.fail(
"No buckets found. All buckets were filtered out by --file option.",
);
process.exit(1);
throw new Error(
"No buckets found. All buckets were filtered out by --file option.",
);
} else {
ora.info(`\x1b[36mProcessing only filtered buckets:\x1b[0m`);
buckets.map((bucket: any) => {
Expand Down Expand Up @@ -296,7 +297,9 @@ export default new Command()
`Localization data has changed; please update i18n.lock or run without --frozen.`,
);
ora.fail(` Details: ${message}`);
process.exit(1);
throw new Error(
`Localization data has changed; please update i18n.lock or run without --frozen. Details: ${message}`,
);
} else {
ora.succeed("No lockfile updates required.");
}
Expand Down Expand Up @@ -499,25 +502,23 @@ export default new Command()
console.log();
if (!hasErrors) {
ora.succeed("Localization completed.");
trackEvent(authId, "cmd.i18n.success", {
await trackEvent(authId, "cmd.i18n.success", {
i18nConfig,
flags,
});
} else {
ora.warn("Localization completed with errors.");
trackEvent(authId || "unknown", "cmd.i18n.error", {
await trackEvent(authId || "unknown", "cmd.i18n.error", {
flags,
});
}
exitGracefully();
} catch (error: any) {
ora.fail(error.message);

trackEvent(authId || "unknown", "cmd.i18n.error", {
await trackEvent(authId || "unknown", "cmd.i18n.error", {
flags,
error,
});
process.exit(1);
}
});

Expand Down
10 changes: 4 additions & 6 deletions packages/cli/src/cli/cmd/run/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from "../../utils/ui";
import trackEvent from "../../utils/observability";
import { determineAuthId } from "./_utils";
import { exitGracefully } from "../../utils/exit-gracefully";

export default new Command()
.command("run")
Expand Down Expand Up @@ -92,7 +91,7 @@ export default new Command()

authId = await determineAuthId(ctx);

trackEvent(authId, "cmd.run.start", {
await trackEvent(authId, "cmd.run.start", {
config: ctx.config,
flags: ctx.flags,
});
Expand All @@ -113,13 +112,12 @@ export default new Command()
await watch(ctx);
}

trackEvent(authId, "cmd.run.success", {
await trackEvent(authId, "cmd.run.success", {
config: ctx.config,
flags: ctx.flags,
});
exitGracefully();
} catch (error: any) {
trackEvent(authId || "unknown", "cmd.run.error", {});
process.exit(1);
await trackEvent(authId || "unknown", "cmd.run.error", {});
throw error;
}
});
26 changes: 15 additions & 11 deletions packages/cli/src/cli/utils/observability.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import pkg from "node-machine-id";
const { machineIdSync } = pkg;

export async function createPosthogClient() {
const { PostHog } = await import("posthog-node");
const posthog = new PostHog(
"phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk",
{
host: "https://eu.i.posthog.com",
flushAt: 1,
flushInterval: 0,
},
);

return posthog;
}

export default async function trackEvent(
distinctId: string | null | undefined,
event: string,
Expand All @@ -13,15 +27,7 @@ export default async function trackEvent(
try {
const actualId = distinctId || `device-${machineIdSync()}`;

const { PostHog } = await import("posthog-node");
const posthog = new PostHog(
"phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk",
{
host: "https://eu.i.posthog.com",
flushAt: 1,
flushInterval: 0,
},
);
const posthog = await createPosthogClient();

await posthog.capture({
distinctId: actualId,
Expand All @@ -34,8 +40,6 @@ export default async function trackEvent(
},
},
});

await posthog.shutdown();
} catch (error) {
if (process.env.DEBUG) {
console.error(error);
Expand Down
17 changes: 15 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.