Hi, I am not sure if this is an appwrite function issue but I am supposing so. I have something I wanna loop for every entry in a list returning type Future<> building a new List<MyClass>. It works for some certain length of the list (4-5 at max). The rest fails in "An internal curl error has occurred within the executor! Error Msg: Operation timed out" ❌
List<CalendarWeek> newCalendarWeeks =
await Future.wait(calendarWeeks.map((e) => getFilledCalendarWeek(
e,
databases,
databaseId,
userId,
)));
Thought it is something with the map but same for: ❌
List<Future<CalendarWeek>> test = [];
for (CalendarWeek calendarWeek in calendarWeeks) {
test.add(getFilledCalendarWeek(
calendarWeek,
databases,
databaseId,
userId,
));
}
List<CalendarWeek> newCalendarWeeks = await Future.wait(test);
This is a workaround that was fine for my test runs: ✅
List<CalendarWeek> newCalendarWeeks = [];
for (int i = 0; i < calendarWeeks.length; i += 4) {
int? endIndex = (i + 4) < calendarWeeks.length ? (i + 4) : null;
List<CalendarWeek> subList = calendarWeeks.sublist(i, endIndex);
newCalendarWeeks.addAll(await Future.wait(
subList.map((calendarWeek) => getFilledCalendarWeek(
calendarWeek,
databases,
databaseId,
userId,
))));
}
So it basically is about the length of entries I add in the "Future.wait([])".
Is this a common behaviour and I am missing something?
Thank you guys!
Btw:
getFilledCalendarWeek(...)));
Makes multiple reads on multiple database collections.
Also it is a self-hosted server. Not cloud.
Right, the server might not be able to handle all the requests. Chunking it is a good approach
[SOLVED] Appwrite function issue with Future.wait for a lot of entries
Recommended threads
- I can't UNPAUSE my project with the free...
I received an email notifying me that my project had been paused due to inactivity, and the email included a link to "Restore project." However, that button red...
- How to bypass the rate limit on the back...
Once a month my app has a ton of usage and I always run into the Too many requests 429 error. I am trying to optimize the queues and jobs to manage that, but a...
- Error trying to deploy functions from CL...
✗ Error • on-auth-create (6a00b2ab000c9ce2949b) • Server Error ✗ Error: No functions were pushed. Prject ID: 69ffe0270033a4ac420a