Skip to content

fix: sync Node preflight range with package.json engines#854

Merged
gewenyu99 merged 2 commits into
mainfrom
posthog-code/sync-node-version-preflight
Jul 10, 2026
Merged

fix: sync Node preflight range with package.json engines#854
gewenyu99 merged 2 commits into
mainfrom
posthog-code/sync-node-version-preflight

Conversation

@gewenyu99

Copy link
Copy Markdown
Collaborator

Problem

The runtime Node version check in bin.ts still enforces >=18.17.0, while package.json engines requires >=22.22.0. npx doesn't enforce engines (it only warns), so users on older Node runtimes pass the preflight and crash later inside dependencies with cryptic errors instead of a clear upgrade message.

Reported via wizard@posthog.com: a user on an old Node runtime was routed to the pi harness, whose bundled undici@8.5.0 calls markAsUncloneable (added in Node 22.10) at module load — surfacing as API Error: webidl.util.markAsUncloneable is not a function immediately after login. Present on a small but steady share of pi-harness runs since the experiment started.

Changes

  • Bump NODE_VERSION_RANGE in bin.ts from >=18.17.0 to >=22.22.0, matching engines.node, with a comment explaining why the preflight must stay in sync.

Known limitation (follow-up candidate): on Node 18 the preflight is unreachable entirely — dist/bin.js is ESM, so its static import graph parses before any code runs, and string-width@8's /v regex flag is a SyntaxError on Node 18's V8. Giving those users a friendly message requires a dependency-free entry wrapper that checks the version before dynamically importing the real bin.

Test plan

  • pnpm build (includes smoke + warlock tests) — passed
  • pnpm vitest run — 96 files, 1305 tests passed
  • pnpm fix — clean

Why

A support report showed old-Node users hitting an instant, misleading "API Error" right after authentication; the stale preflight is the root cause and this makes it fail fast with a clear upgrade message.


Created with PostHog Code

The bin.ts runtime check still allowed Node >=18.17.0 while engines
requires >=22.22.0. npx does not enforce engines, so users on older Node
runtimes slipped through the preflight and crashed inside dependencies
with cryptic errors instead of getting the upgrade message.

Generated-By: PostHog Code
Task-Id: 7901cd0a-07f4-4964-ad71-79a3b0c9c146
@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 basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci mcp-analytics
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /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 error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/cicd-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-nested-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-single-stage-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-gitlab-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-pnpm-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-raw-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-ssh-vps-node-raw
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@gewenyu99 gewenyu99 marked this pull request as ready for review July 10, 2026 01:53
@gewenyu99 gewenyu99 requested a review from a team as a code owner July 10, 2026 01:53
@gewenyu99 gewenyu99 enabled auto-merge (squash) July 10, 2026 16:16
@gewenyu99 gewenyu99 merged commit 569051b into main Jul 10, 2026
16 checks passed
@gewenyu99 gewenyu99 deleted the posthog-code/sync-node-version-preflight branch July 10, 2026 16:18
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.

2 participants