Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions pkgs/cli/examples/async-function-hang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Flow } from '@pgflow/dsl';

type Input = {
logo_url: string;
company_slug: string;
company_id: string;
};

// Dummy async task that simulates real async work
async function processCompanyLogoTask(input: { logo_url: string; company_slug: string }) {
// Simulate some async work with a promise
await new Promise((resolve) => setTimeout(resolve, 100));
return {
file_path: `/uploads/${input.company_slug}/logo.png`,
};
}

// Another dummy async task
async function updateCompanyLogoUrlTask(input: { company_id: string; file_path: string }) {
// Simulate some async work
await new Promise((resolve) => setTimeout(resolve, 50));
return {
success: true,
company_id: input.company_id,
logo_url: input.file_path,
};
}

export default new Flow<Input>({
slug: 'upload_company_logo',
maxAttempts: 3,
timeout: 60,
baseDelay: 2,
})
.step(
{ slug: 'process_company_logo' },
async (input) => await processCompanyLogoTask({
logo_url: input.run.logo_url,
company_slug: input.run.company_slug,
})
)
.step(
{ slug: 'update_company_logo_url', dependsOn: ['process_company_logo'] },
async (input) => await updateCompanyLogoUrlTask({
company_id: input.run.company_id,
file_path: (input.process_company_logo as { file_path: string }).file_path,
})
);
12 changes: 11 additions & 1 deletion pkgs/cli/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"test:vitest",
"test:e2e:install",
"test:e2e:install:duplicates",
"test:e2e:compile"
"test:e2e:compile",
"test:e2e:async-hang-issue-123"
],
"options": {
"parallel": false
Expand Down Expand Up @@ -77,6 +78,15 @@
"cwd": "{projectRoot}",
"parallel": false
}
},
"test:e2e:async-hang-issue-123": {
"executor": "nx:run-commands",
"local": true,
"dependsOn": ["build"],
"options": {
"command": "./scripts/test-async-hang-issue-123",
"cwd": "{projectRoot}"
}
}
}
}
56 changes: 56 additions & 0 deletions pkgs/cli/scripts/test-async-hang-issue-123
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
set -e

# Script to test if pgflow CLI compile hangs on flows with async functions
# This reproduces issue #123: https://github.com/pgflow-dev/pgflow/issues/123
#
# Issue: Compilation hangs on flow with async functions
# Reporter: @cpursley
# Description: Running compile on a flow with async function handlers was hanging.
# After commenting out the async keywords, compilation worked.

cd "$(dirname "$0")/.."
ROOT_DIR=$(pwd)

echo "🧪 Testing async function compilation"
echo " Issue #123: https://github.com/pgflow-dev/pgflow/issues/123"
echo ""

# Clean up any existing output
echo "🧹 Cleaning up old test directory"
rm -rf supabase/

# Initialize a fresh Supabase project
echo "🏗️ Creating new Supabase project"
npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings

# Install pgflow with our CLI
echo "📦 Installing pgflow with CLI"
node dist/index.js install --supabase-path supabase/ --yes

# Try to compile the flow with async functions
echo "🔧 Compiling flow with async functions"
timeout 30s node dist/index.js compile examples/async-function-hang.ts --deno-json examples/deno.json --supabase-path supabase || {
EXIT_CODE=$?
if [ $EXIT_CODE -eq 124 ]; then
echo "❌ FAILURE: Compilation hung and was killed by timeout (30s)"
echo "This confirms issue #123 - compilation hangs on flows with async functions"
exit 1
else
echo "❌ FAILURE: Compilation failed with exit code $EXIT_CODE"
exit $EXIT_CODE
fi
}

# Verify compilation succeeded
echo "✅ Verifying flow compilation"
if ! grep -q "create_flow.*upload_company_logo" supabase/migrations/*.sql; then
echo "❌ FAILURE: No migration found with create_flow for 'upload_company_logo'"
exit 1
fi

# Show success message
echo ""
echo "✨ Async function compilation test complete!"
echo " Issue #123 appears to be fixed or not reproducible in this environment."
echo " See: https://github.com/pgflow-dev/pgflow/issues/123"
Loading