Skip to content

Commit 06883bd

Browse files
author
georgiy.rusanov
committed
deleted all logging
1 parent 1b5c308 commit 06883bd

File tree

3 files changed

+9
-243
lines changed

3 files changed

+9
-243
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -121,135 +121,8 @@ jobs:
121121
run: |
122122
supabase start
123123
124-
- name: Debug Supabase connectivity
125-
run: |
126-
echo "Checking HTTP endpoint with curl"
127-
curl -v http://127.0.0.1:54321 || echo "curl failed"
128-
129-
echo "Testing WebSocket connection to supabase realtime with auth"
130-
# Test WebSocket connection with proper authentication parameters
131-
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==" "http://127.0.0.1:54321/realtime/v1/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0" || echo "WS connection failed"
132-
133-
echo "Testing direct WebSocket connection to realtime service (bypassing Kong)"
134-
# Test direct connection to realtime service on port 4000
135-
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==" "http://127.0.0.1:4000/socket/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0" || echo "Direct WS connection failed"
136-
137-
echo "Testing realtime endpoint directly"
138-
curl -v http://127.0.0.1:54321/realtime/v1/ || echo "Realtime endpoint failed"
139-
140-
echo "Testing realtime health check"
141-
curl -v http://127.0.0.1:54321/realtime/v1/api/ping || echo "Realtime ping failed"
142-
143-
echo "Testing realtime health check with auth"
144-
curl -v -H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" http://127.0.0.1:54321/realtime/v1/api/ping || echo "Realtime ping with auth failed"
145-
146-
echo "Testing realtime subscription endpoint"
147-
curl -v -X POST -H "Content-Type: application/json" -H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" -d '{"channel":"test-channel","type":"broadcast"}' http://127.0.0.1:54321/realtime/v1/api/broadcast || echo "Realtime broadcast failed"
148-
149-
echo "Testing direct realtime service endpoints"
150-
curl -v http://127.0.0.1:4000/api/ping || echo "Direct realtime ping failed"
151-
curl -v -H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" http://127.0.0.1:4000/api/ping || echo "Direct realtime ping with auth failed"
152-
153-
echo "Testing WebSocket connection with Node.js"
154-
npm install ws || echo "Failed to install ws package"
155-
node -e "
156-
const WebSocket = require('ws');
157-
const ws = new WebSocket('ws://127.0.0.1:54321/realtime/v1/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0');
158-
159-
ws.on('open', () => {
160-
console.log('WebSocket connection opened');
161-
// Send a phx_join message
162-
const joinMessage = JSON.stringify({
163-
topic: 'realtime:test-channel',
164-
event: 'phx_join',
165-
payload: {
166-
config: { broadcast: { self: false }, presence: { key: '' }, private: false },
167-
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
168-
},
169-
ref: '1'
170-
});
171-
console.log('Sending join message with full payload:');
172-
console.log(JSON.stringify(JSON.parse(joinMessage), null, 2));
173-
ws.send(joinMessage);
174-
});
175-
176-
ws.on('message', (data) => {
177-
console.log('Received message:', data.toString());
178-
try {
179-
const parsed = JSON.parse(data.toString());
180-
console.log('Parsed message:', JSON.stringify(parsed, null, 2));
181-
} catch (e) {
182-
console.log('Could not parse message as JSON');
183-
}
184-
});
185-
186-
ws.on('error', (error) => {
187-
console.log('WebSocket error:', error.message);
188-
});
189-
190-
ws.on('close', (code, reason) => {
191-
console.log('WebSocket closed:', code, reason.toString());
192-
});
193-
194-
setTimeout(() => {
195-
console.log('Closing WebSocket connection');
196-
ws.close();
197-
}, 5000);
198-
" || echo "Node.js WebSocket test failed"
199-
200-
echo "Testing JWT token validation"
201-
node -e "
202-
const jwt = require('jsonwebtoken');
203-
204-
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0';
205-
const secret = 'super-secret-jwt-token-with-at-least-32-characters-long';
206-
207-
try {
208-
const decoded = jwt.verify(token, secret);
209-
console.log('JWT token is valid');
210-
console.log('Decoded payload:', JSON.stringify(decoded, null, 2));
211-
} catch (error) {
212-
console.log('JWT token validation failed:', error.message);
213-
}
214-
" || echo "JWT validation test failed"
215-
216-
docker ps --format '{{.Names}}'
217-
218-
echo "docker logs"
219-
for name in $(docker ps --format '{{.Names}}'); do
220-
echo "Logs for $name:"
221-
docker logs --tail 20 $name || echo "No logs for $name"
222-
done
223-
224-
echo "Checking realtime container specifically"
225-
docker logs supabase_realtime_supabase-js --tail 50 || echo "No realtime logs"
226-
227-
echo "Checking Kong logs for WebSocket requests"
228-
docker logs supabase_kong_supabase-js --tail 20 || echo "No Kong logs"
229-
230-
echo "Checking if realtime service is properly configured"
231-
docker exec supabase_realtime_supabase-js env | grep -E "(REALTIME|POSTGRES|JWT)" || echo "No realtime env vars found"
232-
233124
- name: Build and test expo
234-
env:
235-
SUPABASE_URL: http://127.0.0.1:54321
236-
SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
237125
run: |
238-
echo "Waiting for realtime service to be fully initialized"
239-
sleep 30
240-
241-
echo "Checking realtime service health..."
242-
for i in {1..10}; do
243-
if curl -s http://127.0.0.1:54321/realtime/v1/api/ping | grep -q "Success"; then
244-
echo "Realtime service is healthy"
245-
break
246-
else
247-
echo "Waiting for realtime service to be ready... (attempt $i/10)"
248-
sleep 5
249-
fi
250-
done
251-
252-
echo "Running Expo app test with environment variables"
253126
npm clean-install
254127
npm run build
255128
PKG=$(npm pack)

examples/expo-app/__tests__/Index.test.tsx

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,30 @@ describe('Index', () => {
77
})
88

99
it('should display SUBSCRIBED status when realtime connection is established', async () => {
10-
console.log('Starting realtime connection test...')
11-
console.log('Environment variables:')
12-
console.log('- SUPABASE_URL:', process.env.SUPABASE_URL || 'not set')
13-
console.log('- SUPABASE_ANON_KEY:', process.env.SUPABASE_ANON_KEY ? 'set' : 'not set')
14-
1510
const { getByTestId, unmount } = render(<Index />)
1611

1712
// Initially, the text should be empty
1813
expect(getByTestId('realtime_status')).toHaveTextContent('')
1914

20-
// Add some initial debugging
21-
console.log('Component rendered, waiting for realtime status')
22-
2315
// Wait for the subscription status to be updated
2416
await waitFor(
2517
() => {
2618
const status = getByTestId('realtime_status').props.children
27-
console.log('Current realtime status:', status)
28-
29-
// Add more debugging for CI
30-
if (status === 'TIMED_OUT') {
31-
console.log('Status is TIMED_OUT - this indicates a connection issue')
32-
} else if (status === 'CHANNEL_ERROR') {
33-
console.log('Status is CHANNEL_ERROR - this indicates a channel subscription issue')
34-
} else if (status === 'CLOSED') {
35-
console.log('Status is CLOSED')
36-
} else if (!status) {
37-
console.log('Status is empty')
38-
}
39-
4019
expect(status).toBe('SUBSCRIBED')
4120
},
4221
{
43-
timeout: 90000, // 90 seconds timeout for waitFor (increased for CI)
22+
timeout: 30000, // 30 seconds timeout for waitFor
4423
interval: 1000, // Check every second
4524
onTimeout: (error) => {
4625
const currentStatus = getByTestId('realtime_status').props.children
47-
console.error('Test timeout. Current status:', currentStatus)
48-
console.error('Environment check:')
49-
console.error('- SUPABASE_URL:', process.env.SUPABASE_URL)
50-
console.error(
51-
'- SUPABASE_ANON_KEY:',
52-
process.env.SUPABASE_ANON_KEY ? 'present' : 'missing'
53-
)
54-
console.error('the realtime connection failed')
5526
throw new Error(
5627
`Timeout waiting for SUBSCRIBED status. Current status: ${currentStatus}. ${error.message}`
5728
)
5829
},
5930
}
6031
)
6132

62-
console.log('Test completed successfully')
6333
// Unmount the component to trigger cleanup.
6434
unmount()
65-
}, 100000) // 100 seconds timeout for the entire test (increased for CI)
35+
}, 35000) // 35 seconds timeout for the entire test
6636
})

examples/expo-app/app/index.tsx

Lines changed: 7 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,24 @@ import { Text, View } from 'react-native'
22
import { useState, useEffect } from 'react'
33
import { createClient } from '@supabase/supabase-js'
44

5-
// Use environment variables with fallbacks for local development
6-
const SUPABASE_URL = process.env.SUPABASE_URL || 'http://127.0.0.1:54321'
5+
const SUPABASE_URL = 'http://127.0.0.1:54321'
76
const ANON_KEY =
8-
process.env.SUPABASE_ANON_KEY ||
97
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
108

11-
console.log('Using Supabase URL:', SUPABASE_URL)
12-
console.log('Using Supabase Key:', ANON_KEY.substring(0, 20) + '...')
13-
14-
const supabase = createClient(SUPABASE_URL, ANON_KEY, {
15-
realtime: {
16-
params: {
17-
eventsPerSecond: 10,
18-
},
19-
},
20-
})
9+
const supabase = createClient(SUPABASE_URL, ANON_KEY)
2110

2211
export default function Index() {
2312
const [realtimeStatus, setRealtimeStatus] = useState<string | null>(null)
13+
const channel = supabase.channel('realtime:public:todos')
2414

2515
useEffect(() => {
26-
console.log('Setting up realtime connection...')
27-
console.log('Realtime URL:', supabase.realtime.endPoint)
28-
console.log('Realtime client:', supabase.realtime)
29-
30-
// Check if we can access the WebSocket connection
31-
try {
32-
console.log('Realtime client properties:', Object.keys(supabase.realtime))
33-
console.log(
34-
'Realtime client methods:',
35-
Object.getOwnPropertyNames(Object.getPrototypeOf(supabase.realtime))
36-
)
37-
} catch (error) {
38-
console.log('Error accessing realtime client properties:', error)
16+
if (channel.state === 'closed') {
17+
channel.subscribe((status) => {
18+
if (status === 'SUBSCRIBED') setRealtimeStatus(status)
19+
})
3920
}
4021

41-
// Use a simpler channel name for testing
42-
const channel = supabase.channel('test-channel')
43-
44-
console.log('Created channel:', channel)
45-
console.log('Channel state:', channel.state)
46-
47-
const subscription = channel.subscribe((status) => {
48-
console.log('Realtime status callback received:', status)
49-
console.log('Channel state after status:', channel.state)
50-
console.log('Channel topic:', channel.topic)
51-
52-
// Add more detailed debugging for WebSocket state
53-
if (supabase.realtime.conn) {
54-
console.log('WebSocket readyState:', supabase.realtime.conn.readyState)
55-
console.log('WebSocket URL:', supabase.realtime.conn.url)
56-
}
57-
58-
// Show all statuses, not just SUBSCRIBED
59-
setRealtimeStatus(status)
60-
})
61-
62-
console.log('Subscription result:', subscription)
63-
64-
// Add a timeout to check if we're stuck
65-
const timeoutId = setTimeout(() => {
66-
console.log('Timeout check - Current realtime status:', realtimeStatus)
67-
console.log('Timeout check - Channel state:', channel.state)
68-
console.log('Timeout check - Channel topic:', channel.topic)
69-
70-
// Check WebSocket connection state
71-
if (supabase.realtime.conn) {
72-
console.log('Timeout check - WebSocket readyState:', supabase.realtime.conn.readyState)
73-
console.log('Timeout check - WebSocket URL:', supabase.realtime.conn.url)
74-
}
75-
76-
// Check if join push was sent
77-
if (channel.joinPush) {
78-
console.log('Timeout check - Join push sent:', channel.joinPush.sent)
79-
console.log('Timeout check - Join push ref:', channel.joinPush.ref)
80-
console.log('Timeout check - Join push receivedResp:', channel.joinPush.receivedResp)
81-
}
82-
83-
// Try to manually check the connection
84-
try {
85-
console.log('Attempting to check realtime connection manually...')
86-
// This might help us understand what's happening
87-
console.log('All channels:', supabase.getChannels())
88-
89-
// Check connection state
90-
console.log('Realtime connection state:', supabase.realtime.connectionState())
91-
console.log('Realtime is connected:', supabase.realtime.isConnected())
92-
} catch (error) {
93-
console.log('Error checking channels:', error)
94-
}
95-
}, 10000) // Increased timeout to 10 seconds
96-
9722
return () => {
98-
console.log('Cleaning up realtime connection...')
99-
clearTimeout(timeoutId)
10023
channel.unsubscribe()
10124
supabase.realtime.disconnect()
10225
}

0 commit comments

Comments
 (0)