Skip to content

feat(test): run dev-mode tests under the real alchemy dev sidecar topology - #1010

Merged
sam-goodwin merged 6 commits into
mainfrom
test/dev-sidecar-default
Aug 1, 2026
Merged

sam-goodwin merged 6 commits into
mainfrom
test/dev-sidecar-default

Conversation

@sam-goodwin

Copy link
Copy Markdown
Member

Dev-mode tests now run local providers behind the same RpcProviderProxy sidecar topology the real alchemy dev command uses — by default. In-process dev tests masked missing main-process lifecycle dependencies (#1007 shipped broken because only Test.make was ever exercised), and flipping the default immediately surfaced two more real dev bugs, fixed here.

const { test, deploy, destroy } = Test.make({
  providers: Cloudflare.providers(),
  dev: true, // ← now implies the alchemy dev RPC sidecar topology
});

// opt out to pin the in-process path (programmatic deploy({ dev: true }),
// local-mode row deletes during a plain deploy) or to debug provider code:
Test.make({ providers, dev: true, sidecar: false });
  • Test/Core.ts: sidecar option defaults to the resolved dev flag. Fully lazy — only a thin proxy facade is installed; the spawner HTTP server starts (and a sidecar child forks) on the first provider session request, so dev files that never build an RPC-backed provider start no processes. One sidecar per file, in its own scope (mid-file destroy(Stack) closes the shared scope and must not kill it), closed by the adapters' final cleanup hook. All three adapters (alchemy-test, Bun, Vitest) wired.
  • Local/RpcSerialization.ts (dev bug feat: remove most HKTs and simplify types #1): RPC success values now get the same Redacted/Output marker treatment as args. Previously a provider returning attributes containing a Redacted (e.g. a local container's bound env with a minted API token) crashed the sidecar response with TypeError: Cannot serialize value: <redacted> under alchemy dev.
  • Cloudflare/D1/Database.ts (dev bug chore: add README #2, the Local D1 migrations and imports fail in dev: missing cloudflare-runtime/Runtime #1007/fix(cloudflare): provide runtime for local D1 migrations #1009 follow-up): the local provider is now RPC-backed (RpcProvider.effect + registered in the sidecar entry), so its migration/import lifecycle runs where localRuntimeServices() is real — the explicit localD1GatewayRuntime provides from fix(cloudflare): provide runtime for local D1 migrations #1009 are removed. In-process (no proxy) still works via the un-gated dual layer and is pinned by a new regression test.
  • examples/cloudflare-dev/test/dev.test.ts: a true alchemy dev CLI e2e — spawns the actual CLI (spawner → exec child → provider sidecars), parses the stack outputs, and drives every local binding over HTTP: assets, vars/secrets, self_url, Durable Object, R2, D1 with ./migrations applied through the real dev path, Queue + Consumer, wasm, Effect-style KV, Workflow to completion, and the sandbox container. Teardown delivers Ctrl-C to the process group and destroys the isolated dev-cli-test stage.
  • test/Local/TestSidecar.test.ts: pins the harness contract (dev: true ⇒ proxy installed, sidecar: false ⇒ not) — sidecar tests would silently pass in-process if the flag wiring regressed, so this is the only guard.
  • Local suites simplified accordingly (D1/KV/R2/Queue/handoff); Worker local tests gain http://localhost dev-marker assertions; Command/Dev.test.ts's typed-CommandError test is pinned sidecar: false (typed errors flatten to defects across the RPC boundary, same as real dev).

Verified: bun tsc -b clean; 50/50 across the 15 dev-mode suites, Container dev matrix 6/6 (previously failing 4 on the Redacted bug), and the CLI e2e passes with 19 assertions and a clean process tree.

Pre-existing, unrelated: test/Local/RpcSpawnerCleanup.test.ts > DevServer child dies after parent receives SIGTERM flakes on unmodified main (verified via stash) — worth a separate look.

@alchemy-version-bot

alchemy-version-bot Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

bun add alchemy@https://pkg.ing/alchemy/a603ce0

@alchemy.run/better-auth

bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/a603ce0

@alchemy.run/pr-package

bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/a603ce0

… topology by default

Test.make({ dev: true }) now installs the RpcProviderProxy sidecar topology
the alchemy dev CLI uses, so dev tests can no longer pass in-process while
the real dev path is broken (#1007). Flipping the default surfaced and fixes
two real dev bugs: RPC success values dropping Redacted secrets, and D1's
plain local provider needing workerd services in the main process (now
RPC-backed in the sidecar like its peers). Adds a true alchemy dev CLI e2e
to examples/cloudflare-dev covering every local binding.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sam-goodwin
sam-goodwin force-pushed the test/dev-sidecar-default branch from 1df3b53 to 56abfbe Compare August 1, 2026 05:41
sam-goodwin and others added 5 commits July 31, 2026 23:02
…t in runMain teardown

The platform runMain only force-exits on failure or signal; a successful
deploy/destroy lingered ~100s while Cloudflare API keep-alive sockets
pinned the event loop. Teardown now always exits once finalizers have run
(same pattern as the alchemy-test CLI).

Co-authored-by: Cursor <cursoragent@cursor.com>
…rvers don't orphan

The node-utils lockfile registers an exit-hook at import time whose
SIGTERM handler calls process.exit synchronously, preempting the Effect
finalizers that kill CommandExecutor children — on node sidecars this
orphaned every Command.Dev process. Register a sync exitHook per spawn
that kills the child's process group (the same pattern RpcSpawner uses),
unregistered on normal scoped teardown. Extracts killProcessGroup into a
shared util.

Co-authored-by: Cursor <cursoragent@cursor.com>
- long-running.cjs prints a localhost URL so Dev's 5s URL-readiness
  budget resolves immediately in lifecycle tests (42s -> 12s)
- RpcServer.test.ts runs its runtimes concurrently so the two ~10s
  parent-connect timeout tests overlap (21s -> 11s)

Co-authored-by: Cursor <cursoragent@cursor.com>
@sam-goodwin
sam-goodwin merged commit 70ebd99 into main Aug 1, 2026
4 checks passed
@sam-goodwin
sam-goodwin deleted the test/dev-sidecar-default branch August 1, 2026 07:00
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