Skip to content

runner: migrate example installs to pnpm#41

Draft
demtario wants to merge 11 commits into
feature/dev-2025-modernize-handsontable-18from
feature/runner-pnpm-installs
Draft

runner: migrate example installs to pnpm#41
demtario wants to merge 11 commits into
feature/dev-2025-modernize-handsontable-18from
feature/runner-pnpm-installs

Conversation

@demtario

Copy link
Copy Markdown
Contributor

Summary

  • Migrates the runner's Tier-2 container example installs from npm/yarn to pnpm, isolating the pnpm dependency cache and sandbox dependency files per session.
  • Adds validation for sandbox file operations and removes the previous unsafe dependency cache.
  • Rolls up prior example-modernization work (Next.js 16/React 19, Remix 2 + HT 18, Angular standalone/HT 18, Astro v7, Vite-based example1) that this branch was built on top of.

Test plan

  • pnpm install at repo root and in runner/
  • node scripts/prepare-container.mjs --all regenerates container contexts cleanly
  • npx wrangler dev locally spins up Tier-2 containers using pnpm installs without errors
  • Spot-check a couple of Tier-2 examples (e.g. Next.js, Remix, Angular) load and hot-reload correctly

🤖 Generated with Claude Code

@demtario demtario self-assigned this Jul 14, 2026
@demtario demtario changed the base branch from master to feature/dev-2025-modernize-handsontable-18 July 14, 2026 12:47
@demtario demtario force-pushed the feature/runner-pnpm-installs branch from b51ae74 to f4277a3 Compare July 14, 2026 13:24
demtario added 5 commits July 14, 2026 17:01
The message named only Vue/Angular from when those were the only
container-engine examples; it now covers react-js, ant-design, mui,
and base-web too, and was masking real session-start errors behind
confusing wording.
pnpm (10.33-10.34), unlike npm, does not strip the -- separator when
the target script resolves to a real binary — it forwards a literal
"--" as the script's first argument. Vite's CLI treats that as "stop
parsing options," so --host/--port silently become inert positional
args instead of flags, and the dev server never actually binds where
the readiness probe expects it (stuck "Booting preview..." forever).

Switch react-js/ant-design/mui/base-web/remix to `pnpm exec <bin>
<flags>`, matching vue's already-correct invocation.
wrangler.jsonc sets PREVIEW_HOST to demos.handsontable.com unconditionally
(vars apply to both wrangler dev and wrangler deploy), a real public
wildcard that routes to the deployed worker, not the local one. Container
preview sessions started via local wrangler dev were getting a previewUrl
on that domain, so the iframe hit prod and got INVALID_TOKEN for a
session/token prod never issued. Overriding PREVIEW_HOST="" in .dev.vars
falls back to the request host, resolving as *.localhost:8787 (RFC 6761)
back to the local worker.
When routes are declared in wrangler.jsonc, wrangler dev simulates the
first route's host on every request (request.url and Host both become
demos.handsontable.com regardless of the actual request hostname; only
the pathname passes through). That destroys the
<port>-<sandboxId>-<token>.* preview hostnames the Sandbox SDK's
proxyToSandbox() routes by, so Tier-2 local preview could never work —
no PREVIEW_HOST value could fix it. There is no config key or CLI flag
to disable the simulation (wrangler gates it on inferOriginFromRoutes,
which only the programmatic startWorker API can set).

Declare no routes in wrangler.jsonc and attach the production routes
via `wrangler deploy --routes …` in the deploy script instead. With no
routes, wrangler dev passes the real Host through verbatim, so
*.localhost:8787 preview URLs (PREVIEW_HOST="localhost:8787" in
.dev.vars) flow through the exact same proxyToSandbox() path as
production — HTML, assets, and the HMR WebSocket all verified working
locally, including two concurrent sessions and token rejection.

Also corrects the local-dev docs from the previous commit: an
empty-string PREVIEW_HOST override is silently ignored by wrangler; it
must be set to a real value, and removing routes from the dev config is
the other required half of the recipe.

Caveat: the --routes flags cannot carry zone_name; wrangler infers the
zone on real deploys (dry-run validated the flags but not inference) —
watch the first production deploy.
Records why wrangler.jsonc must not declare routes (wrangler dev
simulates the first route's host on every request, destroying the
preview hostnames proxyToSandbox routes by), corrects ADR-0011's
local-dev claim, and documents the rejected path-based-proxy
alternative and the deploy-time zone-inference caveat.
@demtario demtario force-pushed the feature/runner-pnpm-installs branch from f85528c to f544a0c Compare July 14, 2026 15:02
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.

1 participant