shiny / adonis-resque

Resque Queue for AdonisJS v6
https://packages.adonisjs.com/packages/resque
MIT License
11 stars 2 forks source link

Issue with the delayQueueLock Plugin #5

Closed filipebraida closed 1 week ago

filipebraida commented 2 weeks ago

I am using your library and writing a Job. I was considering using the delay plugin, and TypeScript is throwing the following error when I use it:

Property 'plugins' in type 'AnswerMessage' is not assignable to the same property in base type 'BaseJob'.
  Type '[typeof DelayQueueLock][]' is not assignable to type '[typeof Plugin, any][]'.
    Type '[typeof DelayQueueLock]' is not assignable to type '[typeof Plugin, any]'.
      Source has 1 element(s) but target requires 2.ts(2416)

Here is my code:

export default class Job extends BaseJob {
  plugins = [Plugin.delayQueueLock()]
  async perform(id: number) {}
}

Thanks!

shiny commented 2 weeks ago

Thank you for let me know, I have confirmed the problem, I will try to fix it.

shiny commented 2 weeks ago

You can upgrade to version 1.2.3 by pnpm update adonis-resque

Additionally, I have added documentation explaining the use for delayQueueLock:

see: https://github.com/shiny/adonis-resque?#plugindelayqueuelock

shiny commented 1 week ago

I will close this issue, if you have any more questions, please reopen it.

filipebraida commented 1 week ago

I have a question, but I would still research better in the node-resque repository. The situation involves trying to enqueue a new job with a delay that is already waiting. In this case, it throws an exception ("Job already enqueued at this time with same arguments").

My test started with this plugin, and I tried to implement it. From what I analyzed, the plugin is not called when the job is delayed, meaning the beforeQueue is only called when the time is up. I think this is more a matter related to node-resque.

Thanks for the help! I just had to force the installation because Virk updated the Redis package :)

shiny commented 1 week ago

I have also encountered this error "Job already enqueued at this time with same arguments", the related issue is https://github.com/actionhero/node-resque/issues/284

Sometimes I noticed the node-resque's documentation is not enough for me, I have to read the source code to understand it.

filipebraida commented 1 week ago

@shiny Thanks for the response! I agree with you. What I was going to try to look into is accessing the API to control and avoid duplicating the job. Their documentation isn't one of their strong points.