Skip to content

fix(install): survive npm override conflicts and bundle jsonc-parser - #1088

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixwizard-survive-npm-dependency-e7202b
Draft

fix(install): survive npm override conflicts and bundle jsonc-parser#1088
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixwizard-survive-npm-dependency-e7202b

Conversation

@posthog

@posthog posthog Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

  • First-run onboarding dies on two separate wizard failures, each a hard stop with no user-side workaround; roughly one in ten terminal setup runs ends in an error state.
  • npm override conflict. A user whose package.json pins a package in its overrides block hits npm error code EOVERRIDE. The wizard had no handling for this — its only tolerance flag is --legacy-peer-deps for React 19 — so the install aborted the whole run before the agent stage that opens the pull request. The npm error text was only written to a local log, never captured as an event property, so the failure class could not be sized.
  • Boot crash. The top-level import * as jsonc from 'jsonc-parser' resolves to the package UMD entry, whose require('./impl/format') survives into a downstream single-file wizard.cjs. Inside Node's embedded runtime that require cannot resolve, so the wizard fails to start — not just the MCP step.

Changes

  • Recover from EOVERRIDE instead of aborting. installPackage now runs the install through a helper, and on failure reads the npm error code. When the code is EOVERRIDE, the manager is npm, and the project declares an override block (overrides / resolutions / pnpm.overrides), it retries once with --force rather than ending the run.
  • Count the failure class. Every failed install records a package install failed event with error_code; each recovery attempt records package install retried with recovered.
  • Bundle jsonc-parser from its ESM build. tsdown.config.ts aliases jsonc-parser to its ESM entry and inlines it (deps.alwaysBundle). The bundler resolves every submodule at build time, so no runtime require('./impl/*') survives. Every other dependency stays external — verified by diffing the externalized imports before and after.
- skipNodeModulesBundle: true,
+ deps: { alwaysBundle: [/^jsonc-parser/] },
+ alias: { 'jsonc-parser': 'jsonc-parser/lib/esm/main.js' },

Test plan

  • pnpm build && pnpm test — 1847 tests pass; build smoke tests pass.
  • New unit tests cover extractNpmErrorCode and hasDependencyOverrides.
  • Verified the built dist/ contains no require("./impl/*") from jsonc-parser and that the diff of externalized imports before/after is exactly jsonc-parser moving from external to bundled.

LLM context

Scope is the wizard repo only. The linked report also names a cloud-side change (run_wizard.py, RetryPolicy(maximum_attempts=1)) in the posthog/posthog repo that discards a failed run and its pull request; that softening lives in a separate repository and is not part of this PR. The report's first suggestion — importing jsonc-parser's ESM build directly — was rejected: the ESM build uses extensionless imports and the package has no "type": "module", so a plain deep import breaks the wizard's own Node runtime. Bundling the ESM build sidesteps that.


Created with PostHog Desktop from this inbox report.

Recover from EOVERRIDE npm install failures instead of aborting the run, and
bundle jsonc-parser from its ESM build so no runtime require survives into a
single-file build.

- installPackage retries a failed npm install once with --force when the error
  is EOVERRIDE and the project declares a dependency override block, and records
  the npm error code on new `package install failed` / `package install retried`
  events so the failure class is countable.
- tsdown inlines jsonc-parser via its ESM entry, so the UMD `require('./impl/*')`
  no longer reaches a downstream single-file build that crashes at boot.

Generated-By: PostHog Desktop
Task-Id: 8b4cf26f-9645-446e-8a97-6b0e0cff3062
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue
  • /wizard-ci self-driving

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/groq
  • /wizard-ci ai-observability/manual-capture
Show more apps
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit

Results will be posted here when complete.

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.

0 participants