Back

Realtime : Unhandled Exception : Concurrent modification during iteration

  • 0
  • Self Hosted
  • Flutter
  • Realtime
Jamy
29 Apr, 2024, 11:03

Hello, I have an issue with the realtime functionnality. At first, connection is working well, and events in the db are triggered. But after some time, like maybe one or two minutes, the subscription randomly fails (onDone is called) and I have the following error : E/flutter (19415): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Concurrent modification during iteration: _Map len:0.

I have a self hosted Appwrite with the version 1.5.4. The server is in a local machine (localhost, Debian 11), and linked to a DNS domain by Cloudflare. In the client part, I use the appwrite package for Flutter with the version 12.0.3.

I uploaded a minimal code example where I meet this problem. It's been 2 days I'm searching on Discord/Github/Stackoverflow issues, but none helped me to fix it.

Do you have ideas how to solve this? Thank you for your time!

TL;DR
Issue with realtime functionality causing errors during iteration. Logs show connection reset by peer on server side and Cloudflare error of incoming request ending abruptly. Self-hosted Appwrite version 1.5.4 on local machine linked to Cloudflare DNS. Using Flutter appwrite package version 12.0.3. Developer seeking help to resolve 'Concurrent modification during iteration' error. Solution: Consider checking the code for potential concurrent modification issues within the map iteration.
Jamy
29 Apr, 2024, 11:17

On the server side, the logs from the cmd docker compose logs -f appwrite-realtime give me :

appwrite-realtime | Notice: PDOStatement::execute(): Send of 397 bytes failed with errno=104 Connection reset by peer in @swoole/library/core/Database/PDOStatementProxy.php on line 44 appwrite-realtime | appwrite-realtime | Notice: PDO::__construct(): Send of 5 bytes failed with errno=104 Connection reset by peer in /usr/src/code/app/init.php on line 848 appwrite-realtime | Connection open (user: 563) appwrite-realtime | appwrite-realtime | Notice: PDOStatement::execute(): Send of 383 bytes failed with errno=104 Connection reset by peer in @swoole/library/core/Database/PDOStatementProxy.php on line 44 appwrite-realtime | Connection close: 563 appwrite-realtime | Connection open (user: 564) appwrite-realtime | Connection open (user: 565) appwrite-realtime | Connection close: 564

And the logs from the Cloudflare :

2024-04-28T12:47:55Z ERR error="Incoming request ended abruptly: context canceled" connIndex=0 event=1 ingressRule=0 originService=http://localhost 2024-04-28T12:47:55Z ERR Request failed error="Incoming request ended abruptly: context canceled" connIndex=0 dest=(...)/v1/avatars/initials?name=Jamy&width=80&height=80&project=console event=0 ip=(...) type=http

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more