diff --git a/.gitignore b/.gitignore index 540213e6..8dfe52ca 100644 --- a/.gitignore +++ b/.gitignore @@ -110,4 +110,6 @@ docs/v2 test/*/package-lock.json test/integration/*/package-lock.json -.cursor/ \ No newline at end of file +.cursor/ + +deno.lock \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7edcf9ac..3fc7b33e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@supabase/functions-js": "2.4.5", "@supabase/node-fetch": "2.6.15", "@supabase/postgrest-js": "1.19.4", - "@supabase/realtime-js": "2.15.0", + "@supabase/realtime-js": "2.15.1-next.1", "@supabase/storage-js": "^2.10.4" }, "devDependencies": { @@ -1126,9 +1126,9 @@ } }, "node_modules/@supabase/realtime-js": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.15.0.tgz", - "integrity": "sha512-SEIWApsxyoAe68WU2/5PCCuBwa11LL4Bb8K3r2FHCt3ROpaTthmDiWEhnLMGayP05N4QeYrMk0kyTZOwid/Hjw==", + "version": "2.15.1-next.1", + "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.15.1-next.1.tgz", + "integrity": "sha512-88WLld7BFsit/3+CDmVBXnPer1OtqiVmNg8OpguL0Vvw492BIp6MdiRXWLbHpfGKUjwxQykDfnY6gs0/NPcgKw==", "license": "MIT", "dependencies": { "@supabase/node-fetch": "^2.6.13", diff --git a/package.json b/package.json index 8dab6ac8..9318e5cc 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@supabase/functions-js": "2.4.5", "@supabase/node-fetch": "2.6.15", "@supabase/postgrest-js": "1.19.4", - "@supabase/realtime-js": "2.15.0", + "@supabase/realtime-js": "2.15.1-next.1", "@supabase/storage-js": "^2.10.4" }, "devDependencies": { diff --git a/test/integration.test.ts b/test/integration.test.ts index 227b3890..55478ddc 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -7,8 +7,22 @@ const SUPABASE_URL = 'http://127.0.0.1:54321' const ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' +// For Node.js < 22, we need to provide a WebSocket implementation +// Node.js 22+ has native WebSocket support +let wsTransport: any = undefined +if (typeof WebSocket === 'undefined' && typeof process !== 'undefined' && process.versions?.node) { + try { + wsTransport = require('ws') + } catch (error) { + console.warn('WebSocket not available, Realtime features may not work') + } +} + const supabase = createClient(SUPABASE_URL, ANON_KEY, { - realtime: { heartbeatIntervalMs: 500 }, + realtime: { + heartbeatIntervalMs: 500, + ...(wsTransport && { transport: wsTransport }), + }, }) describe('Supabase Integration Tests', () => { @@ -315,7 +329,10 @@ describe('Storage API', () => { // use service_role key for bypass RLS const SERVICE_ROLE_KEY = process.env.SUPABASE_SERVICE_ROLE_KEY || 'use-service-role-key' const supabaseWithServiceRole = createClient(SUPABASE_URL, SERVICE_ROLE_KEY, { - realtime: { heartbeatIntervalMs: 500 }, + realtime: { + heartbeatIntervalMs: 500, + ...(wsTransport && { transport: wsTransport }), + }, }) test('upload and list file in bucket', async () => {