question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting Could not find job 999 error

See original GitHub issue

Your Environment

  • Plugin version: 7.0.3
  • Platform: Android
  • OS version: Android 11
  • Device manufacturer / model: Android Emulator
  • React Native version (react-native -v): It’s ionic cordova application.
  • Plugin config: { stopOnTerminate: false, startOnBoot: true, minimumFetchInterval: 15, enableHeadless: true, requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY }

Following is the code:

import { Injectable } from '@angular/core';
import { CoreNonInjectableBase } from "../../base/core-noninjectable.base";
import { Network } from "@ionic-native/network";
import { ToastController, Platform } from "ionic-angular";
import BackgroundFetch, { BackgroundFetchConfig } from "cordova-plugin-background-fetch";


/*
  Generated class for the BackgroundServiceProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class BackgroundServiceProvider extends CoreNonInjectableBase {

  constructor(
    private network: Network,
    private platform: Platform,
    private backgroundFetch: BackgroundFetch
  ) {
    super();
    this.platform.ready().then(result => {
      //if (this.platform.is('ios') || this.platform.is('android')) {
        localStorage.setItem('success schedule task', 'init');
        this.onDeviceReady.bind(this)
      //}
    });
  }

  async onDeviceReady() {
    let config: BackgroundFetchConfig = {
      stopOnTerminate: false,
      startOnBoot: true,
      minimumFetchInterval: 15,
      enableHeadless: true,
      requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY
    }
    console.log('device on ready in Background service');
    // Your BackgroundFetch event handler.
    let onEvent = async (taskId) => {
      localStorage.setItem('[BackgroundFetch] event received 121212: ', taskId);
      // Required: Signal completion of your task to native code
      // If you fail to do this, the OS can terminate your app
      // or assign battery-blame for consuming too much background-time
      await BackgroundFetch.finish(taskId);
    };

    // Timeout callback is executed when your Task has exceeded its allowed running-time.
    // You must stop what you're doing immediately BackgroundFetch.finish(taskId)
    let onTimeout = async (taskId) => {
      localStorage.setItem('[BackgroundFetch] TIMEOUT: ', taskId);
      await BackgroundFetch.finish(taskId);
    };

    // Configure the plugin.
    let status = await BackgroundFetch.configure(config, onEvent, onTimeout);
    console.log('[BackgroundFetch] configure, status: ', status);


    await BackgroundFetch.scheduleTask({
      taskId: "com.transistorsoft.downloadWalkthroughData",
      forceAlarmManager: true,
      delay: 6 * 1000,
      periodic: true// <-- milliseconds
    });
  }

  makeServerCall() {
    
  }

}

Expected Behavior

When I terminate application from multitasker then and when I run jobschedular command then it should show log from headless java file.

Actual Behavior

see logs.

Steps to Reproduce

Context

My ionic app works offline and I am using sqlite db in it, so I am trying to pre-download some app data from my web api and store that in sqlite in advance so that users can perform actions without worrying about internet connection.

Debug logs

adb shell cmd jobscheduler run -f com.my.app 999 output: Could not find job 999 in package com.my.app / user 0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
christocracycommented, Oct 8, 2021

I don’t think you understand what JavaScript Function.bind does.


this.onDeviceReady.bind(this)

It doesn’t actually execute onDeviceReady, it returns another Function with its scope changed.

1reaction
christocracycommented, Oct 8, 2021

And in the meantime, be aware that your onDeviceReady is NOT executing, thus BackgroundFetch.configure is not even being executed, which is why you see Could not find job 999 in package com.my.app / user 0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter Background_fetch lib does not run after terminating app
I'm simulating job with this command: adb shell cmd jobscheduler run -f com.mycompany.appname 999 . When app is active or it's in foreground,...
Read more >
getting error Cannot find a 'job started' record in the log - IBM
When trying to run a DataStage job that previously failed - getting error Cannot find a 'job started' record in the log.
Read more >
800 - 999 Error Codes - FairCom
Value Symbolic Constant Explanation 800 TDEP_ERR TRANDEP file operation pending. 801 FBLK_PND Trying to set file block; leave core. 802 FBLK_SUP File block not supported for...
Read more >
System Error Codes (500-999) (WinError.h) - Win32 apps
{Illegal System DLL Relocation} The system DLL %hs was relocated in memory. The application will not run properly. The relocation occurred ...
Read more >
Desktop Underwriter Credit-related Error Codes Job Aid
Note: Typically means that the credit agency could not find the borrower data. • Compare the borrower's information on the credit report with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found