Skip to content

fix(analytics): keep idle socket errors non-fatal - #1199

Closed
jaredrainsha wants to merge 1 commit into
PostHog:mainfrom
jaredrainsha:fix/1198-keep-wizard-alive
Closed

fix(analytics): keep idle socket errors non-fatal#1199
jaredrainsha wants to merge 1 commit into
PostHog:mainfrom
jaredrainsha:fix/1198-keep-wizard-alive

Conversation

@jaredrainsha

Copy link
Copy Markdown

Problem

When posthog-node exception autocapture receives Node HTTP/2's InformationalError: socket idle timeout, it treats the uncaught event as fatal because the wizard has no process-level exception listener. The SDK then flushes and exits the interactive wizard mid-run.

Closes #1198.

Changes

  • install one idempotent wizard-level uncaught-exception handler after PostHog autocapture
  • log and ignore only the exact Node HTTP/2 idle-timeout signature
  • preserve fatal behavior for every other uncaught exception by printing it, flushing analytics with a two-second deadline, and exiting 1
  • forward optional flush deadlines to the PostHog client

Test plan

  • regression tests: 53/53 passed
  • full Vitest suite: 2607/2607 passed with four workers and a 10-second per-test timeout
  • production build, CLI smoke test, and Warlock security smoke test passed
  • Prettier passed; ESLint reported 0 errors
  • real posthog-node probe stayed alive for the exact idle timeout and exited 1 for a generic error

LLM context

Implemented and verified with OpenAI Codex assistance. The root cause was confirmed against the installed posthog-node 5.45.2 exception-autocapture behavior, and the final diff was constrained to the wizard process boundary and its tests.

@gewenyu99

Copy link
Copy Markdown
Collaborator

Hey, appreciate the fix here. I have a different fix in #1203

I will keep an eye on this and bump packages that depend on undici. I really don't wanna add a catch at the root level for an exception that should have never made it outside the MCP package we use.

@gewenyu99 gewenyu99 closed this Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wizard exits mid-run with "InformationalError: socket idle timeout"

2 participants