-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connectivity issues and "bad file descriptor" errors #5631
Comments
Its related to this issue: #3865 and we are using suggested comment here to address the issue: #3865 (comment) |
Hello @damir-fell, I'm sorry you are experiencing these issues. Can you please try updating to the latest release 2.5.0 of amplify-flutter and report back if it solved the issue? |
Hi @ekjotmultani
It will take some time due to the breaking changes and I would like to resolve the issue as quickly as possible |
Hello @damir-fell
You can migrate from "Gen 1 v1" to "Gen 1 v2" using this guide.
|
Thanks for the response, we will update the library and Flutter version and see. About reproduction, its not really a code snippet or something I can share. Basically our app uses a bunch of subscriptions, queries and mutations and we seem to get problems when app has been in background for a long time and when put to foreground we get many "failed to lookup host" and "bad file descriptor" issues. It funnily enough doesn't look like subscriptions are the issues, but rather queries and mutations. Here are a couple of examples
It is not internet issues as this happens with multiple users on random timestamps, and its occurring as long as app is alive. If app is killed and opened again the issues are gone. We stop subscriptions when app is put to background and restore it when app is put to foreground but the issues keep reappearing either way as long as the app session is active. |
Hi, Just adding my teams experience with this issue, we don't use subscriptions in our app and I receive this issue when trying to make a GraphQL Query from the background using the API. We do this to keep the app data up to date with the server so that the user is always greeted with the latest data from the database. I've had to move off Datastore in preparation of moving to Gen2 and issues with syncing from our lambda function that populates data in the database. We are already using amplify Gen1v2 and Amplify API version 2.5.0. I use the background_fetch v1.3.5 to perform app tasks in the background. Interestingly, I am able to upload files to S3 in the same background process but when querying with the Amplify API package I receive the below error.
A simple reproduction of my set-up is below, background_fetch requires a bit of set-up in the iOS side to get running so if there's fixes I can try I'm happy to help. import 'package:amplify_api/amplify_api.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:background_fetch/background_fetch.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import '../models/ModelProvider.dart';
Future<List<Score?>?> fetchLatestScores() async {
GraphQLRequest<PaginatedResult<Score>> request = ModelQueries.list<Score>(
Score.classType,
limit: 1000
);
try {
GraphQLResponse<PaginatedResult<Score>> response = await Amplify.API
.query(request: request)
.response;
return response.data?.items;
} catch (err) {
safePrint("Received error when requesting latest Scores");
safePrint(err);
return null;
}
}
// Initialize background fetch
Future<void> initBackgroundFetch() async {
int status = await BackgroundFetch.configure(
BackgroundFetchConfig(
minimumFetchInterval: 30,
stopOnTerminate: false,
enableHeadless: true,
requiresBatteryNotLow: true,
requiresCharging: false,
requiresStorageNotLow: false,
requiresDeviceIdle: false,
requiredNetworkType: NetworkType.ANY,
),
(String taskId) async {
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult.contains(ConnectivityResult.wifi) ||
connectivityResult.contains(ConnectivityResult.mobile)) {
try {
//Uploads to S3 using Amplify succeed successfully in the background
//That's what this below function does which I have removed for replication
// FileStorage().uploadPendingFiles();
final newScores = await fetchLatestScores();
safePrint("Received newScores: $newScores");
} catch (err) {
safePrint(
"Received error when trying to fetch scores in the background");
safePrint(err);
}
BackgroundFetch.finish(taskId);
}
},
(String taskId) async {
safePrint("[BackgroundFetch] TASK TIMEOUT taskId: $taskId");
BackgroundFetch.finish(taskId);
},
);
safePrint("[BackgroundFetch] configured successfully: $status");
} |
Hi @nathcakes, apologies for the delayed response, this is interesting and I'm sorry you are facing this issue, I'll attempt to reproduce this on my end, thanks for the sample given it will be helpful! |
Hi @ekjotmultani, We have updated our app to the newest version and are still experiencing the same issues. What should we try now? Any logging we can enable to help get to bottom of the issue? Please assist. |
Description
Hello,
In our app we are experiencing the issue described in this dart issue thread: dart-lang/http#197. Going through our code it seems that we are doing everything right in terms of stopping subscriptions and similar when app goes to background but for some reason it doesnt look like the connection pool is cleared.
We want to try to replace the http client Amplify is using with http_cupertino on ios as suggested by that thread. How can we do this? Do we need to do something within the amplify libraries itself or how is the http package provided?
Categories
Steps to Reproduce
It is usually reproduced when app goes to foreground after being in background for extended period of time. What happens is that all queries start to fail and any retries or similar later does not recover the issue. The app has to be restarted in order to recover.
Screenshots
No response
Platforms
Flutter Version
3.13.8
Amplify Flutter Version
1.7.0
Deployment Method
AWS CDK
Schema
No response
The text was updated successfully, but these errors were encountered: