react-native-job-queue icon indicating copy to clipboard operation
react-native-job-queue copied to clipboard

TypeError: undefined is not an object (evaluating '_this$workers$workerN.isBusy')

Open MrWarzo opened this issue 2 years ago • 5 comments

Hello,

I tried some things with this lib, and everything was good... but now, whatever i'm doing i get this error, even with the doc example :/

This happen when I use the "addJob" method.

I don't understand at all what the problem.. does someone can help me ?

Job table created.
2023-01-05 17:02:10.602151+0100 Photos & Vidéos[97342:6585161] [javascript] Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not an object (evaluating '_this$workers$workerN.isBusy')
getJobsForWorker$@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:187596:97
tryCatch@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24037:23
invoke@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24207:32
tryCatch@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24037:23
invoke@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24109:30
@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24139:19
tryCallTwo@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:28723:9
doResolve@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:28887:25
Promise@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:28746:14
callInvokeWithMethodAndArg@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24138:33
enqueue@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24143:157
@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24158:69
getJobsForWorker@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:187592:42
_callee3$@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:187106:73
tryCatch@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24037:23
invoke@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24207:32
tryCatch@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24037:23
invoke@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24109:30
@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:24119:21
tryCallOne@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:28714:16
@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:28815:27
@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:29406:26
_callTimer@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:29302:17
_callReactNativeMicrotasksPass@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:29341:17
callReactNativeMicrotasks@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:29551:44
__callReactNativeMicrotasks@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:3057:46
@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:2835:45
__guard@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:3040:15
flushedQueue@/private/var/containers/Bundle/Application/43F837AB-4A17-4F33-A721-F45B3D32965B/Photos & Vidéos.app/main.jsbundle:2834:21
flushedQueue@[native code]
invokeCallbackAndReturnFlushedQueue@[native code]

last try :

    queue.configure({
      onQueueFinish: (executedJobs: Job<any>[]) => {
        console.log('Queue stopped and executed', executedJobs);
      },
    });
    queue.addWorker(
      new Worker('testWorker', async payload => {
        return new Promise<void>(resolve => {
          setTimeout(() => {
            console.log(payload.text);
            resolve();
          }, payload.delay);
        });
      }),
    );
    queue.addJob('testWorker', {text: 'hey !! -> ', delay: 5000});

MrWarzo avatar Jan 05 '23 16:01 MrWarzo

update : this work on an iPhone 8 but not on an iPhone 13

MrWarzo avatar Jan 06 '23 06:01 MrWarzo

Can you provide the code of the initialization of "workerN", seems like something went wrong there. Can you reinstall the testapp on iPhone13 and test again?

SimonErm avatar Jan 09 '23 16:01 SimonErm

Hello, I ran into this error on iOS and seems like it happens randomly.

i am not sure i am using the library in a right way, but it works most of the time.

the error has been logged on different iOS device, from iPhone 8 to iPhone 14 Pro, and the iOS version is from 15.4.1 to 16.3.1

here is the error and where it happens

TypeError: Cannot read property 'isBusy' of undefined

// Queue.ts
private async getJobsForWorker(workerName: string) {
        const { isBusy, availableExecuters } = this.workers[workerName];    // got error here
        if (!isBusy) {
            return await this.jobStore.getJobsForWorker(workerName, availableExecuters);
        } else {
            return await this.getJobsForAlternateWorker();
        }
}

i hope these information can help, and if you need more information plwase let me know, thank you

xeroxcsn avatar Apr 19 '23 05:04 xeroxcsn

@xeroxcsn thank you for the information. Are you calling the removeWorker function somewhere in your code?

SimonErm avatar May 02 '23 12:05 SimonErm

I get this issue as well and am not calling removeWorker anywhere.

I noticed however that I consistently get this issue when running via dev-client in expo. When I make a release build the issue goes away. I believe it has something to do with running via dev-client

anark avatar Mar 14 '24 14:03 anark