The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
updated realtime tests, but still some failing intermittently https://github.com/supabase/realtime/issues/21
awalias0a77b238199d
diff --git a/libraries/supabase-js/src/Supabase.js b/libraries/supabase-js/src/Supabase.jsindex c91ab7e9bee..f58d12af0b8 100644--- a/libraries/supabase-js/src/Supabase.js+++ b/libraries/supabase-js/src/Supabase.js@@ -47,7 +47,6 @@ class Supabase {this.tableName == '*'? 'realtime:*': `realtime:${this.schema}:${this.tableName}${filterString}`- console.log(channel)this.socket = new Socket(socketUrl, { params: { apikey: this.apikey } })this.channel = this.socket.channel(channel)diff --git a/libraries/supabase-js/test/integration/testRealtime.js b/libraries/supabase-js/test/integration/testRealtime.jsindex 17f194c8dd5..373dc2f8762 100644--- a/libraries/supabase-js/test/integration/testRealtime.js+++ b/libraries/supabase-js/test/integration/testRealtime.js@@ -6,7 +6,7 @@ import { createClient } from '../../src'// unsubscribe()// removeSubscription()// getSubscriptions()-describe('test subscribing to an insert', function() {+describe('test various subscriptions', function() {const supabase = createClient('http://localhost:8000', 'examplekey')afterEach(function() {@@ -14,6 +14,7 @@ describe('test subscribing to an insert', function() {for (const sub of subscriptions) {supabase.removeSubscription(sub)}+ console.log('subscriptions removed')})// test adding and removing a subscription@@ -48,7 +49,7 @@ describe('test subscribing to an insert', function() {.then().catch(console.error)})- }).timeout(5000)+ }).timeout(10000)// test events on specific tableit('from("messages").on("*").subscribe()', function(done) {@@ -68,52 +69,65 @@ describe('test subscribing to an insert', function() {.then().catch(console.error)})- }).timeout(5000)+ }).timeout(10000)- // test delete message- it('from("messages").on("DELETE").subscribe()', function(done) {+ // test update message+ it('from(messages).on(UPDATE).subscribe()', function(done) {const callbackAction = function(record) {- assert(record.old.id === 1, 'deleted message does not have correct id')+ assert(+ record.new.message === 'updated message yo',+ 'updated message does not have correct text'+ )done()}const subscription = supabase.from('messages')- .on('DELETE', callbackAction)+ .on('UPDATE', callbackAction).subscribe()subscription.channel.socket.conn.addEventListener('open', function(event) {supabase.from('messages')- .match({ id: 1 })- .delete()- .then()+ .insert([{ message: 'update test', user_id: 1, channel_id: 1 }])+ .then(function(response) {+ supabase+ .from('messages')+ .filter('id', 'eq', response.body[0].id)+ .update({ message: 'updated message yo' })+ .then()+ .catch(console.error)+ }).catch(console.error)})- }).timeout(5000)+ }).timeout(10000)- // test update message- it('from(messages).on(UPDATE).subscribe()', function(done) {+ // test delete message+ it('from("messages").on("DELETE").subscribe()', function(done) {const callbackAction = function(record) {- assert(- record.new.message === 'updated message yo',- 'updated message does not have correct text'- )+ assert(record.old.message === 'delete test', 'deleted message does not have correct id')done()}const subscription = supabase.from('messages')- .on('UPDATE', callbackAction)+ .on('DELETE', callbackAction).subscribe()subscription.channel.socket.conn.addEventListener('open', function(event) {supabase.from('messages')- .match({ id: 1 })- .update({ message: 'updated message yo' })- .then()+ .insert([{ message: 'delete test', user_id: 1, channel_id: 1 }])+ .then(function(response) {+ console.log(response)+ supabase+ .from('messages')+ .filter('id', 'eq', response.body[0].id)+ .delete()+ .then(console.log)+ .catch(console.error)+ }).catch(console.error)})- }).timeout(5000)+ }).timeout(10000)// test on INSERTit('from("*").on("INSERT").subscribe()', function(done) {@@ -122,7 +136,7 @@ describe('test subscribing to an insert', function() {done()}const subscription = supabase- .from('*')+ .from('messages').on('INSERT', callbackAction).subscribe()@@ -133,9 +147,12 @@ describe('test subscribing to an insert', function() {.then().catch(console.error)})- }).timeout(5000)-})+ }).timeout(10000)-after(function() {- setTimeout(() => process.exit(0), 5000)+ after(function() {+ setTimeout(function() {+ console.log('ending process')+ process.exit(0)+ }, 5000)+ })})