feat: add portable runtime e2e tests and worker replacement on deprecation#631
feat: add portable runtime e2e tests and worker replacement on deprecation#631jumski wants to merge 1 commit into
Conversation
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
View your CI Pipeline Execution ↗ for commit e703310
💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗. ☁️ Nx Cloud last updated this comment at |

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-runtimesNX target and corresponding CI job (edge-worker-portable-runtime-e2e) run a shared set of example scenarios against all three runtimes. The test suite coversmax_concurrency,conn_max_pg_default,conn_max_pg_override, andconn_env_varexamples.A shared
portable_examples.jsmodule centralizes handler definitions and configuration for these scenarios, replacing duplicated inline logic that previously lived in each Supabase function'sindex.ts. The individual function files (max_concurrency,conn_max_pg_default,conn_max_pg_override,conn_env_var) now delegate tostartPortableExample.A
portable-process-worker.mjsfixture bootstraps the worker under Node or Bun using the compileddist/index.jsoutput, driven by environment variables.Worker Replacement in HTTP Mode
SupabasePlatformAdapternow supports replacing a deprecated or stopped worker within the same process lifetime rather than requiring a full restart:ensureWorkerStartedloops until a healthy worker exists, serializing concurrent replacement attempts viaworkerReplacementPromiseso only one replacement runs at a time.replaceWorkerstops the old worker, generates a fresh UUID for the replacement (falling back toSB_EXECUTION_IDonly for the first worker), and starts the new worker.workerIdis tracked as instance state rather than read directly from the environment on each request.Workernow exposesisCreated,isStarting,isRunning,isDeprecated, andisStoppedgetters, backed by corresponding additions toWorkerLifecycle,FlowWorkerLifecycle, and theILifecycleinterface.Heartbeat Deprecation Default
Queries.sendHeartbeatnow returns{ is_deprecated: true }when the DB returns no row (e.g., the worker record was deleted), rather thanfalse. 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
startWorkerandstartWorkerWithAuthin 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_atandauthorizationtests are updated to tolerate long-lived local edge isolates from previous runs sharing the same queue, avoiding false failures caused by stale worker state.SupabasePlatformAdapter.