Repository navigation
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
With the GitHub integration's Deploy to production enabled, every push to the production branch starts a deployment workflow run. Runs for consecutive pushes are not serialized or cancelled, so they overlap whenever pushes arrive less than one run apart (about 7 minutes for 146 Edge Functions in our case). Each run deploys every function in a different order, so for any one function, the run that deploys it last wins. That is often the run for the older commit. The result is that a function keeps serving the previous commit's code while both Supabase Preview checks are green. It stays that way until a later push happens to redeploy it.
Example, from the project's workflow_run_logs (Cloning git repo... git_ref=main, then Deploying Function... slug=<fn>):
| function | run for commit N (started 21:19:50) | run for commit N-1 (started 21:16:11) | served after both green |
|---|---|---|---|
| fn-a | 21:21:19 | 21:17:51 | N ✅ |
| fn-b | 21:20:14 | 21:23:13 | N-1 ❌ |
| fn-c | 21:22:17 | 21:23:16 | N-1 ❌ |
Over 24 hours on a busy day, about 80 runs had at least one function overwritten by an older, still-running run. For about 50 of those overwrites, the function's own import graph differed between the two commits, meaning stale runtime code was served. Those windows lasted from under a minute to 44 minutes. The integration gives no signal at all: both checks are green, and the function's version and updated_at both advance.
To Reproduce
- Connect a repo with many Edge Functions to the GitHub integration, with Deploy to production on.
- Push commit A to the production branch, then push commit B (which changes a module imported by several functions) about 2–3 minutes later, while A's run is still deploying.
- Once both checks are green, read the functions back (
GET /v1/projects/{ref}/functions/{slug}/bodyor the MCPget_edge_function). Some of the functions that import the module serve A's code. - Logs Explorer:
select timestamp, log_attributes['workflow_run'], event_message from logs where source='workflow_run_logs' and event_message like '%Deploying Function%slug=<fn>%' order by timestampshows A's run deploying the function after B's run did.
Expected behavior
The newest pushed commit's code is what ends up deployed. For example, runs for the same production branch could be queued, or a superseded run could be cancelled before its deploy step, as GitHub Actions concurrency groups do. The Branching docs say "the same deployment workflow will be run on every commit pushed to your git branch", with nothing about ordering.
System information
- Hosted project with Branching via GitHub, Deploy to production on (no preview branches)
- Functions are deployed by the integration (not the CLI); about 146 functions, one shared
_shared/directory
Additional context
Related but different: #51535 (git-triggered branch-action redeploys). The dashboard's "Resync branch" (#46723) repairs the state by hand, if someone knows to press it.
Activity
yogiwaran2003 commentedon Oct 21, 2026
@luizfneves404 I would like to solve this issue
efekanbahceci commentedon Oct 21, 2026
I looked into the root cause of this race across the branching workflow runner and the CLI function deployment path. This is a backend orchestration issue in the platform workflow runner rather than something that lives in the
supabase/supabasefrontend/docs monorepo.Why this happens
No per-branch concurrency control on
action_runs:When Deploy to production is enabled, each push to the production branch triggers a separate workflow run (
/v1/projects/{ref}/actions/{run_id}) executing theclone -> pull -> health -> configure -> migrate -> seed -> deployDAG. The runner currently starts overlapping runs for the samebranch_id/project_refconcurrently rather than serializing them in a per-branch queue or canceling superseded in-progress runs.Non-deterministic per-run function deployment order:
During the
deploystep, the Go CLI (pkg/function/deploy.goandpkg/function/batch.go) iterates overconfig.FunctionConfig(map[string]config.Function) usingfor slug, function := range functionConfigand dispatches uploads through a worker queue (queue.NewJobQueue(s.maxJobs)). Because Go randomizes map iteration order on each execution—and individual bundle/upload timings vary under concurrency—two overlapping runs with 100+ functions traverse and upload the function set in different orders.Last-writer-wins on function updates:
Both individual function uploads (
POST /v1/projects/{ref}/functions/deploy/PUT /v1/projects/{ref}/functions/{slug}) and the finalPUT /v1/projects/{ref}/functions(v1-bulk-update-functions) call apply unconditionally without checking whether the callingworkflow_run_idhas been superseded by a newer run for the same branch. Whenever runN-1reaches a given function slug after runNhas already deployed it, runN-1overwrites the bundle with the older commit's artifact and incrementsversion/updated_at, while both runs exit0and report green check runs.Where the fix needs to happen
Since the workflow orchestrator and
/v1/projects/{ref}/actionsexecution engine live in the internal platform backend (outside this repository), this needs to be addressed server-side by the Supabase team:branch_id(especially the production branch) should be serialized per branch, or queued runs should coalesce so that if commitsBandCarrive whileAis running,Afinishes safely and onlyCruns next (orA'sdeploystep is skipped/canceled once superseded).deploy: Thedeploystep and function update endpoints should reject writes from aworkflow_run_idwhen a newer workflow run has already been created or started deploying for the samebranch_id.SahilArate commentedon Oct 24, 2026
Hi @Hallidayo @luizfneves404 here i went through the issue and investigated on my machine please assign it to me i would like to raise PR with the root solution once you assign it to me.
Thank you!
solvionholdings commentedon Oct 30, 2026
Until the runner serializes runs, you can get "newest commit wins" by moving production deploys into a GitHub Actions workflow with a concurrency group.
config.toml). Preview branches keep working.With
cancel-in-progress: falseonly one run executes at a time, and a newer queued run replaces an older pending one, so the last deploy is always the newest queued commit.truewould cancel mid-deploy and leave a mixed set.Verify after a burst of pushes:
supabase functions download <slug>and diff against the commit, or the/functions/{slug}/bodycheck you already use.This matters for security too: a fix to an auth check can be silently reverted for as long as the windows you measured.