Skip to content

Commit 5716dd8

Browse files
authored
ensure ngrok is not used in wss test (#76)
1 parent 339ee6d commit 5716dd8

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/sync-engine/scripts/test-integration-wss.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ echo ""
7777
echo "🚀 Step 2: Starting CLI in WebSocket mode..."
7878
echo ""
7979

80-
# Unset NGROK_AUTH_TOKEN to ensure WebSocket mode
81-
unset NGROK_AUTH_TOKEN
82-
8380
# Start CLI in background with SKIP_BACKFILL for faster startup
84-
cd "$SYNC_ENGINE_DIR" && SKIP_BACKFILL=true node dist/cli/index.js start --database-url "$DATABASE_URL" > /tmp/cli-wss-test.log 2>&1 &
81+
# USE_WEBSOCKET=true forces WebSocket mode even if NGROK_AUTH_TOKEN is present in .env
82+
cd "$SYNC_ENGINE_DIR" && USE_WEBSOCKET=true SKIP_BACKFILL=true node dist/cli/index.js start --database-url "$DATABASE_URL" > /tmp/cli-wss-test.log 2>&1 &
8583
CLI_PID=$!
8684

8785
# Wait for startup (migrations + WebSocket connection)
@@ -96,13 +94,22 @@ if ! ps -p $CLI_PID > /dev/null 2>&1; then
9694
exit 1
9795
fi
9896

97+
# Verify WebSocket mode (must NOT use ngrok)
98+
if grep -q "ngrok tunnel" /tmp/cli-wss-test.log; then
99+
echo "❌ ERROR: Test is using ngrok when it should use WebSocket mode"
100+
echo " Log output:"
101+
tail -20 /tmp/cli-wss-test.log
102+
exit 1
103+
fi
104+
99105
# Check for WebSocket connection in logs
100106
if grep -q "Connected to Stripe WebSocket" /tmp/cli-wss-test.log; then
101107
echo "✓ WebSocket connected successfully"
102108
else
103-
echo "⚠️ WebSocket connection status unknown"
109+
echo "❌ ERROR: WebSocket connection not found in logs"
104110
echo " Log output:"
105111
tail -20 /tmp/cli-wss-test.log
112+
exit 1
106113
fi
107114
echo ""
108115

packages/sync-engine/src/cli/commands.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,9 @@ export async function syncCommand(options: CliOptions): Promise<void> {
330330
// Load configuration
331331
const config = await loadConfig(options)
332332

333-
// Determine mode based on ngrok token availability
334-
const useWebSocketMode = !config.ngrokAuthToken
333+
// Determine mode based on USE_WEBSOCKET env var or ngrok token availability
334+
// USE_WEBSOCKET=true explicitly forces WebSocket mode (useful for tests)
335+
const useWebSocketMode = process.env.USE_WEBSOCKET === 'true' || !config.ngrokAuthToken
335336
const modeLabel = useWebSocketMode ? 'WebSocket' : 'Webhook (ngrok)'
336337
console.log(chalk.blue(`\nMode: ${modeLabel}`))
337338

0 commit comments

Comments
 (0)