-
Notifications
You must be signed in to change notification settings - Fork 15
docs: Add comprehensive guide for auto-compilation flow development and deployment strategies #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: ef187d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit ef187d5
☁️ Nx Cloud last updated this comment at |
af6bcc5 to
d55cc0b
Compare
d55cc0b to
15033f7
Compare
🔍 Preview Deployment: Playground✅ Deployment successful! 🔗 Preview URL: https://pr-253--pgflow-demo.netlify.app 📝 Details:
_Last updated: _ |
15033f7 to
6c46ecb
Compare
6c46ecb to
a25e961
Compare
a25e961 to
cde9b89
Compare
cde9b89 to
56ed82d
Compare
56ed82d to
dcd753f
Compare
| const errorData = await response.json(); | ||
| throw new Error( | ||
| `Flow '${flowSlug}' not found.\n\n` + | ||
| `${errorData.message || 'Did you add it to flows.ts?'}\n\n` + | ||
| `Fix:\n` + | ||
| `1. Add your flow to supabase/functions/pgflow/flows.ts\n` + | ||
| `2. Restart edge functions: supabase functions serve` | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 404 error handling assumes all 404 responses mean the flow wasn't registered, but the ControlPlane server regex /^/flows/([a-zA-Z0-9_]+)$/ only accepts alphanumeric characters and underscores. If a user passes a slug with hyphens like my-flow, the route won't match and returns a generic 404 with "Route GET /flows/my-flow not found". This code will misleadingly tell users to add the flow to flows.ts when the real issue is invalid characters in the slug.
if (response.status === 404) {
const errorData = await response.json();
// Check if it's a route mismatch vs missing flow
if (errorData.error === 'Not Found' && errorData.message.includes('Route')) {
throw new Error(
`Invalid flow slug: '${flowSlug}'\n\n` +
`Flow slugs can only contain letters, numbers, and underscores.\n` +
`Example: my_flow (not my-flow)`
);
}
throw new Error(
`Flow '${flowSlug}' not found.\n\n` +
`${errorData.message || 'Did you add it to flows.ts?'}\n\n` +
`Fix:\n` +
`1. Add your flow to supabase/functions/pgflow/flows.ts\n` +
`2. Restart edge functions: supabase functions serve`
);
}| const errorData = await response.json(); | |
| throw new Error( | |
| `Flow '${flowSlug}' not found.\n\n` + | |
| `${errorData.message || 'Did you add it to flows.ts?'}\n\n` + | |
| `Fix:\n` + | |
| `1. Add your flow to supabase/functions/pgflow/flows.ts\n` + | |
| `2. Restart edge functions: supabase functions serve` | |
| ); | |
| } | |
| const errorData = await response.json(); | |
| // Check if it's a route mismatch vs missing flow | |
| if (errorData.error === 'Not Found' && errorData.message.includes('Route')) { | |
| throw new Error( | |
| `Invalid flow slug: '${flowSlug}'\n\n` + | |
| `Flow slugs can only contain letters, numbers, and underscores.\n` + | |
| `Example: my_flow (not my-flow)` | |
| ); | |
| } | |
| throw new Error( | |
| `Flow '${flowSlug}' not found.\n\n` + | |
| `${errorData.message || 'Did you add it to flows.ts?'}\n\n` + | |
| `Fix:\n` + | |
| `1. Add your flow to supabase/functions/pgflow/flows.ts\n` + | |
| `2. Restart edge functions: supabase functions serve` | |
| ); | |
| } |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
dcd753f to
0d80511
Compare
| find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i 's/\.js"/\.ts"/g' {} + | ||
| find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i "s/\.js'/\.ts'/g" {} + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sed -i flag behaves differently on macOS vs Linux. On macOS, it requires a backup extension argument (e.g., sed -i ''), while on Linux it doesn't. This will cause the script to fail for developers on macOS.
# Fix for cross-platform compatibility:
find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i.bak 's/\.js"/\.ts"/g' {} + && find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.bak" -delete
find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i.bak "s/\.js'/\.ts'/g" {} + && find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.bak" -delete| find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i 's/\.js"/\.ts"/g' {} + | |
| find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i "s/\.js'/\.ts'/g" {} + | |
| find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i.bak 's/\.js"/\.ts"/g' {} + && find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.bak" -delete | |
| find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.ts" -type f -exec sed -i.bak "s/\.js'/\.ts'/g" {} + && find "$VENDOR_DIR/@pgflow/edge-worker" -name "*.bak" -delete | |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
d55d7e7 to
e74ef8e
Compare
| '--control-plane-url <url>', | ||
| 'Control plane URL', | ||
| 'http://127.0.0.1:54321/functions/v1/pgflow' | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Port mismatch with CLI package configuration. The default control plane URL uses port 54321, but pkgs/cli/supabase/config.toml configures the API on port 54421 (line 10). This will cause compilation to fail when users run pgflow compile without the --control-plane-url flag in the CLI package's test environment.
.option(
'--control-plane-url <url>',
'Control plane URL',
'http://127.0.0.1:54421/functions/v1/pgflow' // Fix: use 54421
)The E2E test at pkgs/cli/__tests__/e2e/compile.test.ts:139 already works around this by explicitly passing the correct URL, but the default will fail for users.
| '--control-plane-url <url>', | |
| 'Control plane URL', | |
| 'http://127.0.0.1:54321/functions/v1/pgflow' | |
| ) | |
| '--control-plane-url <url>', | |
| 'Control plane URL', | |
| 'http://127.0.0.1:54421/functions/v1/pgflow' | |
| ) |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
e74ef8e to
e8886cd
Compare
f95d77b to
1ea4670
Compare
| console.error(`[DEBUG] Fetch failed for URL: ${url}`); | ||
| console.error(`[DEBUG] Error message: ${error.message}`); | ||
| console.error(`[DEBUG] Error cause:`, (error as any).cause); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug logging is unconditionally enabled in production. These console.error statements will always print to stderr when fetch fails, creating noise in production logs.
// Remove debug logging or make it conditional:
if (error.message.includes('ECONNREFUSED') || error.message.includes('fetch failed')) {
throw new Error(
'Could not connect to ControlPlane.\n\n' +
// ... rest of error message
);
}| console.error(`[DEBUG] Fetch failed for URL: ${url}`); | |
| console.error(`[DEBUG] Error message: ${error.message}`); | |
| console.error(`[DEBUG] Error cause:`, (error as any).cause); | |
| if (process.env.DEBUG) { | |
| console.error(`[DEBUG] Fetch failed for URL: ${url}`); | |
| console.error(`[DEBUG] Error message: ${error.message}`); | |
| console.error(`[DEBUG] Error cause:`, (error as any).cause); | |
| } |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
| } | ||
|
|
||
| if (filesToCreate.some((f) => f.path === denoJsonPath)) { | ||
| fs.writeFileSync(denoJsonPath, DENO_JSON_TEMPLATE(getVersion())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If getVersion() returns 'unknown', invalid package specifiers like npm:@pgflow/core@unknown will be written to deno.json, causing import failures when the edge function starts.
if (filesToCreate.some((f) => f.path === denoJsonPath)) {
const version = getVersion();
if (version === 'unknown') {
throw new Error('Could not determine package version. Check package.json exists.');
}
fs.writeFileSync(denoJsonPath, DENO_JSON_TEMPLATE(version));
}| fs.writeFileSync(denoJsonPath, DENO_JSON_TEMPLATE(getVersion())); | |
| const version = getVersion(); | |
| if (version === 'unknown') { | |
| throw new Error('Could not determine package version. Check package.json exists.'); | |
| } | |
| fs.writeFileSync(denoJsonPath, DENO_JSON_TEMPLATE(version)); | |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
77bca6f to
c4e9c95
Compare
251ac47 to
b02f41d
Compare
…nd deployment strategies
b02f41d to
ef187d5
Compare
🔍 Preview Deployment: Website✅ Deployment successful! 🔗 Preview URL: https://pr-253.pgflow.pages.dev 📝 Details:
_Last updated: _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merge activity
|
…nd deployment strategies (#253)

No description provided.