fresh icon indicating copy to clipboard operation
fresh copied to clipboard

kvdex.collection.listenQueue not responsive(radio silent) in local development

Open waptik opened this issue 6 months ago • 6 comments

Hi,

I'm using fresh v1.6.1 and kvdex v0.28.3 in a new project and i'm facing some challenges making listenQueue from kvdex responsive. For reference, i fired enqueue() inside a grammY middleware then i placed my listenQueue() inside the main.ts file of my fresh project but nothing happened when enqueue() was being fired(i logged the result inside a console.log and it returned a positive response). Then i decided to do this crazy this crazy thing by wrapping all my listenQueue() inside a queues.ts file in the root folder and calling inside fresh.gen.ts and surprisingly, they started working(I haven't added any new route or island after that). NB: i have yet to try kv.listenQueue() directly inside main.ts file so i don't know if that works for me or not. BTW, my environment is github codespaces

waptik avatar Dec 19 '23 17:12 waptik

Would you mind providing a code example of how listenQueue() was being called in your main.ts file? And possibly how it looks now in your queue.ts file?

I would also suggest trying kv.listenQueue() and kv.enqueue() to identify if it is a kvdex specific issue.

oliver-oloughlin avatar Dec 19 '23 18:12 oliver-oloughlin

Thanks for replying.

  • Here is the code itself when it was being called in main.ts image

  • and it's basically the same thing in my queues.ts file with an extra queue listener image

  • Also, here's how i was using .collection.enqueue image

I tried both kv.listenQueue() and kv.enqueue() but it still didn't catch anything image image

So it looks like it's not kvdex specific issue. I'll create a new fresh project and use a minimal example to reproduce the issue again

waptik avatar Dec 20 '23 07:12 waptik

So i created a simple example inside a new fresh app. When you start the app with deno task start and visit http://localhost:8000/api/joke, you see the output in the terminal

Both listenQueue(), enqueue() from native kv and kvdex are being used inside the main.ts as well as queues.ts files

waptik avatar Dec 20 '23 08:12 waptik

I think this is an issue fresh in local development, in particularly from dev.ts file when because i deployed the example repo to deno deploy, the queues are being processed effectively

image

As a temporary fix, i imported queues.ts inside fresh.config.ts instead of main.ts to make it work in local developement

simplescreenrecorder-2023-12-20_10.24.25.webm

waptik avatar Dec 20 '23 10:12 waptik

@waptik What are the exact steps to reproduce the error?

marvinhagemeister avatar Jan 09 '24 22:01 marvinhagemeister

@waptik What are the exact steps to reproduce the error?

  1. Fork the repo based on this commit in your local environment
  2. Start the app with deno task start
  3. Visit http://localhost:8000/api/joke or HOST_URL/api/joke to add jobs to queue

waptik avatar Jan 10 '24 00:01 waptik