Closed nic86 closed 2 years ago
What does adb logcat show?
with chrome:inspect i discovered that the problem is not at the http request. Error occurs when in the same function get stored data.
the execution stop here:
async get(key:string):Promise <any> {
try {
const val = await this._storage.get(key); //the execution stop here
return val;
} catch(err) {
return Promise.reject(err);
}
}
the storage configuration in app.module.ts is
IonicStorageModule.forRoot({
name: '__dbname',
driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage]
}),
adb logcat shows no error.
adb logcat (first 5 minutes) when the function is running correctly:
08-26 15:57:17.771 17331 17331 D TSBackgroundFetch: - Background Fetch event received: capacitor-background-fetch
08-26 15:57:17.806 17331 17331 I Capacitor/Console: File: http://192.168.0.114:8100/main.js - Line 5266 - Msg: Thu, 26 Aug 2021 13:57:17 GMT : [BackgroundFetch] EVENT: capacitor-background-fetch
08-26 15:57:17.806 17331 17331 I Capacitor/Console: File: http://192.168.0.114:8100/main.js - Line 5266 - Msg: Thu, 26 Aug 2021 13:57:17 GMT : start cron process
08-26 15:57:20.207 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360722, pluginId: Http, methodName: get
08-26 15:57:20.294 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360723, pluginId: Http, methodName: get
08-26 15:57:20.298 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360724, pluginId: Http, methodName: get
08-26 15:57:20.401 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360725, pluginId: Http, methodName: get
08-26 15:57:20.405 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360726, pluginId: Http, methodName: get
08-26 15:57:20.484 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360727, pluginId: Http, methodName: get
08-26 15:57:20.496 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360728, pluginId: Http, methodName: get
08-26 15:57:25.898 17331 17331 I Capacitor/Console: File: http://192.168.0.114:8100/main.js - Line 5266 - Msg: Thu, 26 Aug 2021 13:57:25 GMT : end cron: empty queue
08-26 15:57:25.938 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360729, pluginId: BackgroundFetch, methodName: finish
08-26 15:57:25.942 17331 17453 D TSBackgroundFetch: - finish: capacitor-background-fetch
08-26 15:57:25.942 17331 17453 D TSBackgroundFetch: - jobFinished
adb logcat (after 5 minutes) when the function is not running correctly:
08-26 16:01:01.763 17331 17331 D TSBackgroundFetch: - Background Fetch event received: capacitor-background-fetch
08-26 16:01:01.861 17331 17331 I Capacitor/Console: File: http://192.168.0.114:8100/main.js - Line 5266 - Msg: Thu, 26 Aug 2021 14:01:01 GMT : [BackgroundFetch] EVENT: capacitor-background-fetch
08-26 16:01:01.863 17331 17331 I Capacitor/Console: File: http://192.168.0.114:8100/main.js - Line 5266 - Msg: Thu, 26 Aug 2021 14:01:01 GMT : start cron process
08-26 16:02:01.795 17331 17331 D TSBackgroundFetch: [BGTask] timeout: capacitor-background-fetch
08-26 16:02:01.847 17331 17331 I Capacitor/Console: File: http://192.168.0.114:8100/main.js - Line 5266 - Msg: Thu, 26 Aug 2021 14:02:01 GMT : [BackgroundFetch] TIMEOUT: capacitor-background-fetch
08-26 16:02:01.853 17331 17489 V Capacitor/Plugin: To native (Capacitor plugin): callbackId: 114360730, pluginId: BackgroundFetch, methodName: finish
08-26 16:02:01.853 17331 17453 D TSBackgroundFetch: - finish: capacitor-background-fetch
08-26 16:02:01.853 17331 17453 D TSBackgroundFetch: - jobFinished
i have tested ionic storage driver CordovaSQLiteDriver._driver and Drivers.IndexedDB but neither works
IonicStorageModule.forRoot({
name: '__dbname',
driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage]
}),
IonicStorageModule.forRoot({
name: '__dbname',
driverOrder: [Drivers.IndexedDB, Drivers.LocalStorage]
}),
I tested the ionic driver Drivers.LocalStorage and now it seems to work even after 5 minutes.
IonicStorageModule.forRoot({
name: '__dbname',
driverOrder: [Drivers.LocalStorage, Drivers.IndexedDB]
}),
You seem to be having problems with a 3rd party plugin you're using within your fetch callback.
I see the fetch events operating correctly.
14:01:01 GMT : [BackgroundFetch] EVENT: capacitor-background-fetch
08-26 16:02:01.795 17331 17331 D TSBackgroundFetch: [BGTask] timeout: capacitor-background-fetch
Your Environment
Plugin version: 0.0.6
Platform: Android
Device OS version: Pixel 2 API 29
Device manufacturer / model: Emulator
Capacitor info (
npx cap doctor
)@capacitor/cli: 3.1.2 @capacitor/core: 3.2.0 @capacitor/android: 3.2.0 @capacitor/ios: 3.2.0
Plugin config provided to
BackgroundFetch.configure
:Expected Behavior
get data from storage is executed correctly
Actual Behavior
after five minutes the storage does not work and the timeout function is performed
Context
I put the application in the background. I run the script every minute.
adb shell cmd jobscheduler run -f 999
it only works for the first 5 minutes, after which it stops working.