Skip to content

Commit c6d9573

Browse files
authored
fix: drop commented import from flows index template (#641)
## Why `pgflow install` scaffolded `supabase/flows/index.ts` with a commented-out example import: ```ts // Example: export { MyFlow } from './my-flow.ts'; ``` The Supabase CLI resolves each function's import graph with a **regex over raw file text** (`importPathPattern` in `apps/cli/src/shared/functions/deploy.ts`) — it does not strip comments. The commented example matches the pattern, the walker tries to read `supabase/flows/my-flow.ts`, gets ENOENT, and `supabase start` aborts on a fresh project: ``` failed to read file: open supabase/flows/my-flow.ts: no such file or directory ``` Reproduced in isolation: fresh `supabase init` + the comment in a transitive file → `supabase start` exits with the error above; deleting only that comment line → full stack boots. ## What - `flows/index.ts` template: drop the commented example import, replace with a short warning comment that itself contains no import-shaped text - manual-installation docs: same change in the copy-paste snippet - regression test: generated `index.ts` must not reference `my-flow` ## Verification - `vitest create-flows-directory.test.ts` — 7/7 (new assertion caught an earlier draft of this fix that quoted the forbidden pattern in its own warning comment) - ran supabase CLI's exact `importPathPattern` over the generated file: only `./greet-user.ts` matches, which exists - E2E with the locally built CLI: fresh project → `pgflow install` → `supabase start` boots the full stack (previously failed at bind-mount resolution)
1 parent b9ef4c9 commit c6d9573

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"pgflow": patch
3+
---
4+
5+
Fix freshly installed projects failing to start: the generated `supabase/flows/index.ts` contained a commented-out example import that the Supabase CLI's text-based import scanner treats as a real import, aborting `supabase start` with `failed to read file: supabase/flows/my-flow.ts`.

‎pkgs/cli/__tests__/commands/install/create-flows-directory.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ describe('createFlowsDirectory', () => {
5454
expect(indexContent).toContain("export { GreetUser } from './greet-user.ts';");
5555
// Should have documenting comment
5656
expect(indexContent).toContain('Re-export all flows');
57+
// No commented-out imports: the Supabase CLI regex-scans file text and
58+
// fails `supabase start` on any import of a non-existent file
59+
expect(indexContent).not.toContain('my-flow');
5760
});
5861

5962
it('should create greet-user.ts with named export', async () => {

‎pkgs/cli/src/commands/install/create-flows-directory.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { log, confirm } from '@clack/prompts';
44
import chalk from 'chalk';
55

66
const INDEX_TS_TEMPLATE = `// Re-export all flows from this directory
7-
// Example: export { MyFlow } from './my-flow.ts';
7+
//
8+
// Do not add commented-out import examples: the Supabase CLI scans file
9+
// text for import statements without parsing comments, so an example that
10+
// names a missing file breaks "supabase start" with "failed to read file".
811
912
export { GreetUser } from './greet-user.ts';
1013
`;

‎pkgs/website/src/content/docs/reference/manual-installation.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ Create `supabase/flows/index.ts` to export your flows:
136136

137137
```typescript title="supabase/flows/index.ts"
138138
// Re-export all flows from this directory
139-
// Example: export { MyFlow } from './my-flow.ts';
139+
// (Do not keep commented-out import examples here — the Supabase CLI's
140+
// import scanner treats them as real imports and `supabase start` fails)
140141

141142
export { GreetUser } from './greet-user.ts';
142143
```

0 commit comments

Comments
 (0)