Skip to content

fix(cli): bundle the Go edge-runtime template for offline supabase start#5682

Merged
jgoux merged 1 commit into
developfrom
claude/offline-start-go-template
Jun 24, 2026
Merged

fix(cli): bundle the Go edge-runtime template for offline supabase start#5682
jgoux merged 1 commit into
developfrom
claude/offline-start-go-template

Conversation

@jgoux

@jgoux jgoux commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Makes supabase start start its edge-runtime offline. Follow-up to #5678, which fixed supabase functions serve but not supabase start.

Why a second PR was needed

#5678 fixed the TS template (functions serve, which is a native TS port). But supabase start is wrapped — the legacy shell proxies it to the Go binary (start.handler.tsstart.go:1054 serve.ServeFunctions). Go's edge-runtime embedded its own copy of the bootstrap template (apps/cli-go/internal/functions/serve/templates/main.ts), which still imported https://deno.land/std/... and jsr:@panva/jose@6. So default supabase start (edge-runtime enabled) still crashed offline with the status.ts DNS error from supabase/supabase#45570.

The root cause of the gap was two copies of the same template, only one of which was fixed.

How

Unify on a single source of truth:

  • The Go binary now go:embeds templates/main.bundled.js — the bundle of the canonical apps/cli/src/shared/functions/serve.main.ts (jose + std deps inlined, no remote specifiers), reusing the same bundleServeMainTemplate() from fix(cli): serve edge functions offline by bundling the runtime template #5678.
  • Added scripts/generate-go-serve-template.ts (pnpm generate:go-serve-template) to produce the committed artifact. It's committed because go build/go test/CI have no JS toolchain.
  • Deleted the duplicate Go templates/main.ts.
  • A unit test (serve-main-go-template.unit.test.ts) regenerates the bundle and fails if the committed file drifts from serve.main.ts — so the two CLIs can't silently diverge again.
  • Updated the Go serve test to assert the embedded template is self-contained (no deno.land/jsr:) instead of asserting the old remote imports.

The container launch path is unchanged — Go still heredocs the template into /root/index.ts and runs edge-runtime start --main-service=/root; only the embedded contents differ (now the offline bundle).

Relationship to other fixes

`supabase start` proxies to the Go binary, whose edge-runtime bootstrap template
(`templates/main.ts`) still imported `deno.land/std` and `jsr:@panva/jose` over
the network on every start — so start crashed offline even after the TS
`functions serve` fix (supabase/supabase#45570).

Unify on a single template: the Go binary now embeds the bundle of the canonical
`apps/cli/src/shared/functions/serve.main.ts` (jose + std deps inlined), generated
by `scripts/generate-go-serve-template.ts` and committed as
`templates/main.bundled.js`. The duplicate Go `templates/main.ts` is deleted. A
unit test regenerates the bundle and fails if the committed artifact drifts, so the
two CLIs can't diverge again.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jgoux jgoux requested a review from a team as a code owner June 24, 2026 12:55
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@aeaa67266a81554d05b9b2e98a147e03b7112ce4

Preview package for commit aeaa672.

@jgoux jgoux added this pull request to the merge queue Jun 24, 2026
Merged via the queue into develop with commit 5a7d2e5 Jun 24, 2026
28 checks passed
@jgoux jgoux deleted the claude/offline-start-go-template branch June 24, 2026 13:50
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.

2 participants