Skip to content

Commit ffef99c

Browse files
author
georgiy.rusanov
committed
more logs
1 parent 9dd17a5 commit ffef99c

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ jobs:
139139
echo "Testing realtime health check with auth"
140140
curl -v -H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" http://127.0.0.1:54321/realtime/v1/api/ping || echo "Realtime ping with auth failed"
141141
142+
echo "Testing realtime subscription endpoint"
143+
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"
144+
142145
docker ps --format '{{.Names}}'
143146
144147
echo "docker logs"
@@ -147,17 +150,23 @@ jobs:
147150
docker logs --tail 20 $name || echo "No logs for $name"
148151
done
149152
150-
echo "Checking realtime container specifically..."
153+
echo "Checking realtime container specifically"
151154
docker logs supabase_realtime_supabase-js --tail 50 || echo "No realtime logs"
152155
153-
echo "Checking Kong logs for WebSocket requests..."
156+
echo "Checking Kong logs for WebSocket requests"
154157
docker logs supabase_kong_supabase-js --tail 20 || echo "No Kong logs"
155158
159+
echo "Checking if realtime service is properly configured"
160+
docker exec supabase_realtime_supabase-js env | grep -E "(REALTIME|POSTGRES|JWT)" || echo "No realtime env vars found"
161+
156162
- name: Build and test expo
157163
env:
158164
SUPABASE_URL: http://127.0.0.1:54321
159165
SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
160166
run: |
167+
echo "Waiting for Supabase services to be fully ready"
168+
sleep 10
169+
161170
npm clean-install
162171
npm run build
163172
PKG=$(npm pack)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,26 @@ describe('Index', () => {
1717
// Initially, the text should be empty
1818
expect(getByTestId('realtime_status')).toHaveTextContent('')
1919

20+
// Add some initial debugging
21+
console.log('Component rendered, waiting for realtime status')
22+
2023
// Wait for the subscription status to be updated
2124
await waitFor(
2225
() => {
2326
const status = getByTestId('realtime_status').props.children
2427
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+
2540
expect(status).toBe('SUBSCRIBED')
2641
},
2742
{
@@ -36,6 +51,7 @@ describe('Index', () => {
3651
'- SUPABASE_ANON_KEY:',
3752
process.env.SUPABASE_ANON_KEY ? 'present' : 'missing'
3853
)
54+
console.error('the realtime connection failed')
3955
throw new Error(
4056
`Timeout waiting for SUBSCRIBED status. Current status: ${currentStatus}. ${error.message}`
4157
)

examples/expo-app/app/index.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,55 @@ export default function Index() {
2525
useEffect(() => {
2626
console.log('Setting up realtime connection...')
2727
console.log('Realtime URL:', supabase.realtime.endPoint)
28+
console.log('Realtime client:', supabase.realtime)
2829

29-
const channel = supabase.channel('realtime:public:todos')
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)
39+
}
40+
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)
3051

31-
channel.subscribe((status) => {
32-
console.log('Realtime status:', status)
3352
// Show all statuses, not just SUBSCRIBED
3453
setRealtimeStatus(status)
3554
})
3655

56+
console.log('Subscription result:', subscription)
57+
58+
// Add a timeout to check if we're stuck
59+
const timeoutId = setTimeout(() => {
60+
console.log('Timeout check - Current realtime status:', realtimeStatus)
61+
console.log('Timeout check - Channel state:', channel.state)
62+
console.log('Timeout check - Channel topic:', channel.topic)
63+
64+
// Try to manually check the connection
65+
try {
66+
console.log('Attempting to check realtime connection manually...')
67+
// This might help us understand what's happening
68+
console.log('All channels:', supabase.getChannels())
69+
} catch (error) {
70+
console.log('Error checking channels:', error)
71+
}
72+
}, 5000)
73+
3774
return () => {
3875
console.log('Cleaning up realtime connection...')
76+
clearTimeout(timeoutId)
3977
channel.unsubscribe()
4078
supabase.realtime.disconnect()
4179
}

0 commit comments

Comments
 (0)