Coder Social home page Coder Social logo

Comments (14)

phamhieu avatar phamhieu commented on June 16, 2024 9

I released a new supabase-dart version:

  • fix the casting error
  • fix missing gotrue event on session recover. Thanks @osaxma

Can you give it a try. Thank you

from realtime-dart.

clarky2233 avatar clarky2233 commented on June 16, 2024 5

To reproduce this error on my end I do the following:

  1. Create a table and setup the real time stream (enable replication on that table)
  2. In my flutter front end use the supabase stream() method with a filter e.g. 'countries:id=eq.120' in the select
  3. Use a streambuilder widget to display the stream data
  4. Trigger changes to the rows I am listening to by updating columns in the database
  5. After update to database is made the error then occurs

from realtime-dart.

KirioXX avatar KirioXX commented on June 16, 2024 2

@phamhieu Sorry for the delayed response.

I build a test project to reproduce the issue: https://github.com/KirioXX/supabase_todo .
I'm not sure if it's related to the rls or the number of items,
but when I started to press the todo items in the shared shopping list I get the error message in the picture.
After the message appears the stream connection is gone.
Screenshot 2022-01-22 at 18 10 11

from realtime-dart.

bdlukaa avatar bdlukaa commented on June 16, 2024 2

Closing as resolved!

from realtime-dart.

osaxma avatar osaxma commented on June 16, 2024 1

I found out that the error only occurs when I recover auth session. In other words, subscribing after login directly doesn't have an issue, but subscribing after a session recovery has the issue.

Workaround

After a session recovery, update the accessToken manually for the realtime client :

final res = await supabaseClient.auth.recoverSession(sessionString);
supabaseClient.realtime.setAuth(res.data?.accessToken); // <~~~ this solves it

Issue:

The issue is that onAuthStateChange does not trigger an event after a session recovery, which is used to update the accessToken for the realtime client in here:

https://github.com/supabase-community/supabase-dart/blob/2d5be1c6968da5944f8b3b039e351b38a953d815/lib/src/supabase.dart#L169-L180

If gotrue-dart emits a signedIn or tokenRefreshed event after session recovery, this issue would be fixed.

from realtime-dart.

phamhieu avatar phamhieu commented on June 16, 2024

@KirioXX we deployed supabase-dart v0.2.11 with the latest realtime client.

Can you give it a try and let us know if the problem persists. Thank you.

from realtime-dart.

KirioXX avatar KirioXX commented on June 16, 2024

@phamhieu that's amazing just gave it a try and it's working like a charm. Thank you very much 🙌🌟

from realtime-dart.

KirioXX avatar KirioXX commented on June 16, 2024

@phamhieu not related to this issue.
But we see now with the new version this error messages coming through when we try to sign a user in:

VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: LateInitializationError: Field 'changedAccessToken' has not been initialized.
#0      SupabaseClient.changedAccessToken (package:supabase/src/supabase.dart)
package:supabase/src/supabase.dart:1
#1      SupabaseClient._handleTokenChanged
package:supabase/src/supabase.dart:171
#2      SupabaseClient._listenForAuthEvents.<anonymous closure>
package:supabase/src/supabase.dart:165
#3      GoTrueClient._notifyAllSubscribers.<anonymous closure>
package:gotrue/src/gotrue_client.dart:442
#4      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:539:8)
#5      GoTrueClient._notifyAllSubscribers
package:gotrue/src/gotrue_client.dart:442
#6      GoTrueClient._handleEmailSignIn
package:gotrue/src/gotrue_client.dart:353
<asynchronous suspension>
#7      _LoginPageState._signInEmailPW
package:tusks/…/login/login_page.dart:102
<asynchronous suspension>

can it be that superbase_flutter also needs an update?

from realtime-dart.

KirioXX avatar KirioXX commented on June 16, 2024

Sorry, @phamhieu I think this needs to be reopened we still see the error now it's even more often.
This is the exception that we see now every 60s probably on the heardbeat:

[sentry.runZonedGuarded] [error] Uncaught zone error
[sentry.runZonedGuarded] _CastError (type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String?' in type cast)
[sentry.runZonedGuarded] #0      RealtimeSubscription.onError.<anonymous closure>
package:realtime_client/src/realtime_subscription.dart:97
#1      RealtimeSubscription.trigger
package:realtime_client/src/realtime_subscription.dart:225
#2      RealtimeClient.onConnMessage.<anonymous closure>.<anonymous closure>
package:realtime_client/src/realtime_client.dart:267
#3      Iterable.forEach (dart:core/iterable.dart:279:35)
#4      RealtimeClient.onConnMessage.<anonymous closure>
package:realtime_client/src/realtime_client.dart:266
#5      new RealtimeClient.<anonymous closure>
package:realtime_client/src/realtime_client.dart:88
#6      RealtimeClient.onConnMessage
package:realtime_client/src/realtime_client.dart:251
#7      RealtimeClient.connect.<anonymous closure>
package:realtime_client/src/realtime_client.dart:110
#8      _rootRunUnary (dart:async/zone.dart:1436:47)
#9      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#10     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#11     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#12     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#13     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#14     _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10)
#15     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#16     _rootRunUnary (dart:async/zone.dart:1436:47)
#17     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#18     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#19     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#20     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#21     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#22     _StreamController._add (dart:async/stream_controller.dart:607:7)
#23     _rootRunUnary (dart:async/zone.dart:1436:47)
#24     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#25     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#26     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#27     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#28     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#29     _StreamController._add (dart:async/stream_controller.dart:607:7)
#30     _StreamController.add (dart:async/stream_controller.dart:554:5)
#31     new _WebSocketImpl._fromSocket.<anonymous closure> (dart:_http/websocket_impl.dart:1144:21)
#32     _rootRunUnary (dart:async/zone.dart:1436:47)
#33     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#34     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#35     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#36     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#37     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#38     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#39     _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23)
#40     _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46)
#41     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#42     _rootRunUnary (dart:async/zone.dart:1436:47)
#43     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#44     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#45     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#46     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#47     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#48     _StreamController._add (dart:async/stream_controller.dart:607:7)
#49     _StreamController.add (dart:async/stream_controller.dart:554:5)
#50     _Socket._onData (dart:io-patch/socket_patch.dart:2302:41)
#51     _rootRunUnary (dart:async/zone.dart:1444:13)
#52     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#53     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#54     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#55     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#56     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#57     _StreamController._add (dart:async/stream_controller.dart:607:7)
#58     _StreamController.add (dart:async/stream_controller.dart:554:5)
#59     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1830:33)
#60     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1314:14)
#61     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#62     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

As a short there solution, I tried to catch the error and restart the stream, but I can't pinpoint where the catch needs to happen.

from realtime-dart.

bit-burger avatar bit-burger commented on June 16, 2024

This is also occurring to me, but i fixed it by going back to an older version of supabase_flutter (with an older version of realtime_client

from realtime-dart.

bit-burger avatar bit-burger commented on June 16, 2024

Im on version 0.1.12+1, however on a fork (that was recently merged) (https://github.com/Vinzent03/realtime-dart)

from realtime-dart.

bit-burger avatar bit-burger commented on June 16, 2024

On the newest version 0.1.13 it is not working for me

from realtime-dart.

phamhieu avatar phamhieu commented on June 16, 2024

Hi @KirioXX @bit-burger I can't replicate the error on my side.

Can you provide a step by step guide? It will help a lot. Thank you

from realtime-dart.

bit-burger avatar bit-burger commented on June 16, 2024

Thanks @clarky2233

from realtime-dart.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.