|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# Script to test if pgflow CLI compile hangs on flows with async functions |
| 5 | +# This reproduces issue #123: https://github.com/pgflow-dev/pgflow/issues/123 |
| 6 | +# |
| 7 | +# Issue: Compilation hangs on flow with async functions |
| 8 | +# Reporter: @cpursley |
| 9 | +# Description: Running compile on a flow with async function handlers was hanging. |
| 10 | +# After commenting out the async keywords, compilation worked. |
| 11 | + |
| 12 | +cd "$(dirname "$0")/.." |
| 13 | +ROOT_DIR=$(pwd) |
| 14 | + |
| 15 | +echo "🧪 Testing async function compilation" |
| 16 | +echo " Issue #123: https://github.com/pgflow-dev/pgflow/issues/123" |
| 17 | +echo "" |
| 18 | + |
| 19 | +# Clean up any existing output |
| 20 | +echo "🧹 Cleaning up old test directory" |
| 21 | +rm -rf supabase/ |
| 22 | + |
| 23 | +# Initialize a fresh Supabase project |
| 24 | +echo "🏗️ Creating new Supabase project" |
| 25 | +npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings |
| 26 | + |
| 27 | +# Install pgflow with our CLI |
| 28 | +echo "📦 Installing pgflow with CLI" |
| 29 | +node dist/index.js install --supabase-path supabase/ --yes |
| 30 | + |
| 31 | +# Try to compile the flow with async functions |
| 32 | +echo "🔧 Compiling flow with async functions" |
| 33 | +timeout 30s node dist/index.js compile examples/async-function-hang.ts --deno-json examples/deno.json --supabase-path supabase || { |
| 34 | + EXIT_CODE=$? |
| 35 | + if [ $EXIT_CODE -eq 124 ]; then |
| 36 | + echo "❌ FAILURE: Compilation hung and was killed by timeout (30s)" |
| 37 | + echo "This confirms issue #123 - compilation hangs on flows with async functions" |
| 38 | + exit 1 |
| 39 | + else |
| 40 | + echo "❌ FAILURE: Compilation failed with exit code $EXIT_CODE" |
| 41 | + exit $EXIT_CODE |
| 42 | + fi |
| 43 | +} |
| 44 | + |
| 45 | +# Verify compilation succeeded |
| 46 | +echo "✅ Verifying flow compilation" |
| 47 | +if ! grep -q "create_flow.*upload_company_logo" supabase/migrations/*.sql; then |
| 48 | + echo "❌ FAILURE: No migration found with create_flow for 'upload_company_logo'" |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | + |
| 52 | +# Show success message |
| 53 | +echo "" |
| 54 | +echo "✨ Async function compilation test complete!" |
| 55 | +echo " Issue #123 appears to be fixed or not reproducible in this environment." |
| 56 | +echo " See: https://github.com/pgflow-dev/pgflow/issues/123" |
0 commit comments