fix(cli): force exit after render to prevent process hang (#104)

## Summary

- Adds `process.exit(0)` after render completes in the CLI `render` command
- Fixes the process hanging indefinitely after `npx hyperframes render --output video.mp4`
- Root cause: Node.js `fetch()` keep-alive pool (from update checks and telemetry) keeps TCP connections open, preventing the event loop from draining
- Telemetry is preserved — the `exit` handler in `cli.ts` calls `flushSync()` which spawns a detached child process

## Test plan

- [x] Run `npx hyperframes render --output test.mp4` and verify the process exits after completion
- [x] Verify telemetry events are still sent (check PostHog)
This commit is contained in:
Miguel Ángel
2026-03-28 00:42:01 +01:00
committed by GitHub
parent 704ae15e3c
commit 2f22c3bbc7
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ export async function flush(): Promise<void> {
try {
await fetch(`${POSTHOG_HOST}/batch/`, {
method: "POST",
headers: { "Content-Type": "application/json" },
headers: { "Content-Type": "application/json", Connection: "close" },
body: JSON.stringify({ api_key: POSTHOG_API_KEY, batch }),
signal: controller.signal,
});
+4 -1
View File
@@ -42,7 +42,10 @@ export async function checkForUpdate(force?: boolean): Promise<UpdateCheckResult
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
const res = await fetch(NPM_REGISTRY_URL, { signal: controller.signal });
const res = await fetch(NPM_REGISTRY_URL, {
signal: controller.signal,
headers: { Connection: "close" },
});
clearTimeout(timeout);
if (!res.ok) return fallbackResult(config.latestVersion);