fix(cli): force exit after render to prevent process hang - #104
Merged
Conversation
Node.js keeps the process alive due to lingering HTTP connections from fetch() keep-alive pool (update checks and telemetry). The exit event handler in cli.ts fires flushSync() which spawns a detached child process so telemetry data is not lost. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
The diagnosis is correct — Node.js However,
Adding // updateCheck.ts
const res = await fetch(NPM_REGISTRY_URL, {
signal: controller.signal,
headers: { Connection: "close" },
});
// telemetry/client.ts
await fetch(`${POSTHOG_HOST}/batch/`, {
method: "POST",
headers: { "Content-Type": "application/json", Connection: "close" },
body: JSON.stringify({ api_key: POSTHOG_API_KEY, batch }),
signal: controller.signal,
});With this, the flow becomes:
No |
…t(0) Address PR feedback: the root cause is undici's HTTP keep-alive pool holding TCP sockets open. Adding Connection: close to the update check and telemetry fetch calls lets the event loop drain naturally after render completes, without needing a forced process.exit(0). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
jrusso1020
approved these changes
Mar 27, 2026
dahans-msft2
pushed a commit
to dahans-msft2/hyperframes
that referenced
this pull request
Aug 6, 2026
…#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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
process.exit(0)after render completes in the CLIrendercommandnpx hyperframes render --output video.mp4fetch()keep-alive pool (from update checks and telemetry) keeps TCP connections open, preventing the event loop from drainingexithandler incli.tscallsflushSync()which spawns a detached child processTest plan
npx hyperframes render --output test.mp4and verify the process exits after completion