Skip to content

feat: add portable runtime e2e tests and worker replacement on deprecation#631

Open
jumski wants to merge 1 commit into
portable-worker-docsfrom
portable-worker-runtime-e2e
Open

feat: add portable runtime e2e tests and worker replacement on deprecation#631
jumski wants to merge 1 commit into
portable-worker-docsfrom
portable-worker-runtime-e2e

Conversation

@jumski

@jumski jumski commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This PR introduces portable runtime E2E tests that verify the edge-worker runs correctly across multiple JavaScript runtimes (Node.js, Bun, and Supabase/Deno), alongside several fixes to worker lifecycle management and heartbeat behavior.

Portable Runtime E2E Tests

A new e2e:portable-runtimes NX target and corresponding CI job (edge-worker-portable-runtime-e2e) run a shared set of example scenarios against all three runtimes. The test suite covers max_concurrency, conn_max_pg_default, conn_max_pg_override, and conn_env_var examples.

A shared portable_examples.js module centralizes handler definitions and configuration for these scenarios, replacing duplicated inline logic that previously lived in each Supabase function's index.ts. The individual function files (max_concurrency, conn_max_pg_default, conn_max_pg_override, conn_env_var) now delegate to startPortableExample.

A portable-process-worker.mjs fixture bootstraps the worker under Node or Bun using the compiled dist/index.js output, driven by environment variables.

Worker Replacement in HTTP Mode

SupabasePlatformAdapter now supports replacing a deprecated or stopped worker within the same process lifetime rather than requiring a full restart:

  • ensureWorkerStarted loops until a healthy worker exists, serializing concurrent replacement attempts via workerReplacementPromise so only one replacement runs at a time.
  • replaceWorker stops the old worker, generates a fresh UUID for the replacement (falling back to SB_EXECUTION_ID only for the first worker), and starts the new worker.
  • workerId is tracked as instance state rather than read directly from the environment on each request.
  • Worker now exposes isCreated, isStarting, isRunning, isDeprecated, and isStopped getters, backed by corresponding additions to WorkerLifecycle, FlowWorkerLifecycle, and the ILifecycle interface.

Heartbeat Deprecation Default

Queries.sendHeartbeat now returns { is_deprecated: true } when the DB returns no row (e.g., the worker record was deleted), rather than false. This ensures a worker whose DB record disappears is treated as deprecated and triggers replacement rather than continuing to run silently.

Test and CI Fixes

  • startWorker and startWorkerWithAuth in the E2E helpers now retry if the HTTP response succeeds but the worker doesn't become active within 5 seconds, rather than failing immediately.
  • stopped_at and authorization tests are updated to tolerate long-lived local edge isolates from previous runs sharing the same queue, avoiding false failures caused by stale worker state.
  • Two new unit tests cover the deprecated-worker replacement path and concurrent replacement serialization in SupabasePlatformAdapter.

@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e703310

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

jumski commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@nx-cloud

nx-cloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit e703310

Command Status Duration Result
nx affected -t lint typecheck test --parallel -... ❌ Failed 31s View ↗
nx run edge-worker:test:integration ✅ Succeeded 4m 26s View ↗
nx run edge-worker:e2e:portable-runtimes ✅ Succeeded 1m 36s View ↗
nx run edge-worker:e2e ✅ Succeeded 1m 2s View ↗
nx run client:e2e ✅ Succeeded 1m 15s View ↗
nx run cli:e2e ✅ Succeeded 3s View ↗
nx run core:pgtap ✅ Succeeded <1s View ↗
nx run edge-worker:smoke:bun ✅ Succeeded 5s View ↗

💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗.


☁️ Nx Cloud last updated this comment at 2026-06-09 11:26:50 UTC

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