romanovichim / dartTonconnect

Dart SDK for TON Connect 2.0
MIT License
17 stars 10 forks source link

Assorted failures #11

Open nonlin-lin-chaos-order-etc-etal opened 1 week ago

nonlin-lin-chaos-order-etc-etal commented 1 week ago

JS console:

GET https://bridge.tonapi.io/bridge/events?client_id=c32a4e5a392a96fa301296d2b7a7eba1053e0f981e2a2217692591c0e250e74a&last_event_id=1728325588459596
net::ERR_HTTP2_PROTOCOL_ERROR 200 (OK)
https://bridge.tonapi.io/bridge/events?client_id=c32a4e5a392a96fa301296d2b7a7eba1053e0f981e2a2217692591c0e250e74a&last_event_id=1728325588459596 // 

errors.dart:296 Uncaught DartError: Bad state: Future already completed
    at Object.throw_ [as throw] (errors.dart:296:3)
    at _AsyncCompleter.new.complete (future_impl.dart:43:31)
    at bridge_gateway.dart:54:7
    at Object._checkAndCall (operations.dart:426:37)
    at Object.dcall (operations.dart:431:39)
    at EventSource.<anonymous> (html_dart2js.dart:37260:58)

https://bridge.tonapi.io/bridge/events?client_id=c32a4e5a392a96fa301296d2b7a7eba1053e0f981e2a2217692591c0e250e74a&last_event_id=1728325588459596 has a response.body:

<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">event: heartbeat

event: heartbeat

event: heartbeat

event: heartbeat

event: heartbeat

event: heartbeat

</pre></body></html>

Events event: heartbeat continue to arrive while Google Chrome has the page open

nonlin-lin-chaos-order-etc-etal commented 1 week ago

bridge_gateway.dart:54 is:

  BridgeGateway(this._storage, this._bridgeUrl, this._sessionId, this._listener,
      this._errorsListener) {
    resolve = Completer();
  }

  Future<void> registerSession() async {
    if (_isClosed) {
      return;
    }

    final bridgeBase = _bridgeUrl;
    var bridgeUrl = '$bridgeBase/$ssePath?client_id=$_sessionId';

    final lastEventId = await _storage.getItem(key: IStorage.keyLastEventId);
    if (lastEventId != null) {
      bridgeUrl += '&last_event_id=$lastEventId';
    }

    logger.d('Bridge url -> $bridgeUrl');

    if (_eventSource != null) {
      _eventSource!.close();
    }

    _eventSource = EventSource(bridgeUrl);

    _eventSource!.onError.listen(_errorsHandler);
    _eventSource!.onOpen.listen((_) {
      resolve.complete(true); // HERE IS THE LINE 54
    });