Skip to content

🐛 Bug Report: RealTime subscribe throws Concurrent modification during iteration: _Map len:0 #200

Closed
appwrite/sdk-generator
#824
@darwinmorocho-deuna

Description

@darwinmorocho-deuna

👟 Reproduction steps

Self Hosting with a nginx proxy

nginx configuration

server {
    server_name app.mydomain.com;

    location / {
        proxy_pass http://localhost:81;
	proxy_set_header Host $host;
    }

    location /v1/realtime/ {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://localhost:81/v1/realtime/;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/app.mydomain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/app.mydomain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot



}
server {
    if ($host = app.mydomain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name app.mydomain.com;
    listen 80;
    return 404; # managed by Certbot


}

Flutter SDK

appwrite: ^12.0.3

Try to subscribe to multiples channels

   final Realtime _realtime = Realtime(client);
.
.
.
    final userChannel = 'databases.my_db.collections.users.documents.$userId';
    final membershipChannel = 'databases.my_db.collections.memberships.documents.$userId';
    
    // this works for around 30 seconds, after that time the appwrite sdk throws 
// Unhandled Exception: Concurrent modification during iteration: _Map len:0.
// And the realtime stop working
    _subscription = _realtime.subscribe(
      [userChannel, membershipChannel],
    );

👍 Expected behavior

Realtime must not stop working after some seconds.

👎 Actual Behavior

Console error after 30 seconds.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Concurrent modification during iteration: _Map len:0.
#0      _CompactIterator.moveNext (dart:collection-patch/compact_hash.dart:714:7)
#1      RealtimeMixin._createSocket.<anonymous closure> (package:appwrite/src/realtime_mixin.dart:91:49)
#2      _RootZone.runGuarded (dart:async/zone.dart:1582:10)
#3      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
#4      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
#5      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
#6      _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
#7      _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
#8      _RootZone.runGuarded (dart:async/zone.dart:1582:10)
#9      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

MacOS

🧱 Your Environment

No

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions