fix: add aggressive timeouts to PostHog telemetry to avoid CLI latency#48
Merged
fix: add aggressive timeouts to PostHog telemetry to avoid CLI latency#48
Conversation
Every CLI invocation was taking ~1s due to PostHog's default behavior of waiting indefinitely for telemetry to flush on Close(). This was especially noticeable when the PostHog endpoint was slow or unreachable. Changes: - Set ShutdownTimeout to 100ms (was infinite) to cap Close() wait time - Set BatchUploadTimeout to 200ms (was 10s) to cap HTTP request time - Add custom HTTP transport with 100ms dial/TLS/response timeouts - Add silentLogger to suppress expected timeout warnings The silentLogger is necessary because with these aggressive timeouts, PostHog will frequently log warnings about dropped messages and shutdown timeouts. These are expected and harmless for best-effort telemetry, but would clutter stderr for users. Trade-off: Some telemetry events may be dropped if the network is slow. This is acceptable since telemetry is best-effort and should never impact CLI responsiveness. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Entire-Checkpoint: 9fd2fc39aa5f
Soph
approved these changes
Jan 16, 2026
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.
Description
Every CLI invocation was taking ~1s due to PostHog's default behavior of waiting for telemetry to flush on Close(). This was especially noticeable when the PostHog endpoint was slow or unreachable, and the command (e.g.,
./entire help) should return instantly. This made the UX sluggish.Changes:
The silentLogger is necessary because with these aggressive timeouts, PostHog will frequently log warnings about dropped messages and shutdown timeouts. These are expected and harmless for best-effort telemetry, but would clutter stderr for users.
Trade-off: Some telemetry events may be dropped if the network is slow. This seems acceptable to me, since telemetry is best-effort and should never impact CLI responsiveness.
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com
Entire-Checkpoint: 9fd2fc39aa5f