D
Deno

help

Is there a way to reset/flush my deno vk queues on deploy?

PPinolero12/3/2023
Nothing seems to be queuing. I would like to reset it if possible?
Ffro.profesional12/3/2023
Leave and empty handler maybe?
PPinolero12/3/2023
kv.listenQueue(async (msg: any) => {} ); like so? i'll give it a try
Ccknight12/3/2023
You mention nothing seems to be queuing. What do you mean by this?
PPinolero12/3/2023
I've enqueue items, but with a delay of 100ms - but the items don't seem to execute. Not even console logging the error if any. Note, I was working around in my local environment - testing queues and such. Eventually in my local environment, it stopped working. (simply delaying messages to log to console). Then I made some adjustments, deployed to deno deploy - and started testing out my queues in live environment. Now, it stopped working. I'm not sure if my local changes kv queues changes deployed to deno deploy and got it stuck?
Ccknight12/3/2023
Can you share enqueue and listenQueue code?
PPinolero12/3/2023
//routes/api/emailer
const QueueAccountForEmailing = async (items: any, emailType: string) => {
const rowIds = items;
//console.log(`queuing row ids: ${rowIds}`);
console.log(`size of rowIds: ${rowIds.length}`);
for (const id of rowIds) {
await kv.enqueue(
{ type: "emailer", id: id, emailType }, { delay: 100 }
);
}
}


export const handler = {
async POST(_req:any) {
const payload = (await _req.json());
await QueueAccountForEmailing(payload.items, payload.emailType);
return new Response();
}
};

//queues.ts
import { kv } from "./kv.ts";
import { ExecuteWebhook } from "../routes/api/renewalupdate.ts";
import { CheckifEmailSentAndSendMail } from "../routes/api/emailer.ts";
import { GetAccountScrape } from "../routes/api/scraper.ts";

kv.listenQueue(async (msg: any) => {
if (msg.type === "emailer") {
await CheckifEmailSentAndSendMail(msg.id, msg.emailType);
}
if (msg.type === "scraper") {
await GetAccountScrape(msg.id);
}
if (msg.type === "update") {
await ExecuteWebhook(msg.id);
}
});
//routes/api/emailer
const QueueAccountForEmailing = async (items: any, emailType: string) => {
const rowIds = items;
//console.log(`queuing row ids: ${rowIds}`);
console.log(`size of rowIds: ${rowIds.length}`);
for (const id of rowIds) {
await kv.enqueue(
{ type: "emailer", id: id, emailType }, { delay: 100 }
);
}
}


export const handler = {
async POST(_req:any) {
const payload = (await _req.json());
await QueueAccountForEmailing(payload.items, payload.emailType);
return new Response();
}
};

//queues.ts
import { kv } from "./kv.ts";
import { ExecuteWebhook } from "../routes/api/renewalupdate.ts";
import { CheckifEmailSentAndSendMail } from "../routes/api/emailer.ts";
import { GetAccountScrape } from "../routes/api/scraper.ts";

kv.listenQueue(async (msg: any) => {
if (msg.type === "emailer") {
await CheckifEmailSentAndSendMail(msg.id, msg.emailType);
}
if (msg.type === "scraper") {
await GetAccountScrape(msg.id);
}
if (msg.type === "update") {
await ExecuteWebhook(msg.id);
}
});
running this using deno fresh in deno deploy, in the analytics section - it does show as writes occuring. I just don't know why it isn't running. My delay is only 100ms I'm only using kv for the queues, so there are no other writes anywhere. And btw, I am not sending mail from deno deploy. It's just pointing to an aws endpoint that connects to my business exchange account.
Ccknight12/3/2023
Is queues.ts imported anywhere?
PPinolero12/3/2023
no it isn't
Ccknight12/3/2023
Ah, then it can't be discovered and registered
PPinolero12/3/2023
thas crazy though .. its been like this for 3 days. It was never imported anywhere and it was running!
Ccknight12/3/2023
For simplicity, try copying that queues.ts code into your fresh main.ts file
PPinolero12/3/2023
okay, i'll try that hello, thanks, that seemed to do the trick! thanks a lot I appreciate it. But no shit... I swear I had my listenQueue in another file, NOT being imported at all. It was working.... on local and deploy. I appreciate the support 🙏
Ccknight12/3/2023
Excellent! Great to hear it's working now. I suspect you might also be able to import queues.ts I think, but I kind of prefer the explicit declaration in main.ts. You could always shift the logic of the listener to another module.

Looking for more? Join the community!

Recommended Posts
Return lazy struct fields from OpMy goal is to build a plugin system which allows invoking user defined code. One of the features I aRelative path in WebSocketWhy does relative path in `WebSocket` not work?Relative path in `npm:` specifierI have this in my import map: ``` "@heroicons/react/": "npm:@heroicons/react@2.0.18/" ``` And I try Transitive dependencies with node_modulesHi all, today I stumbled upon this not-sure-if-a-bug: ```ts import { LRParser } from "npm:@lezer/lrUpgraded to Fresh 1.60 but TailwindCSS not renderingI updated my codebase to Fresh 1.60 using TailwindCSS instead of twind. When I pushed the code to DeOptimize for Prod simple static vanilla JS script - WebServer App with Oak + DEJSUsing DEJS to render views. Those views are served by Oak, according to the defined routes. What is ReadableStream passed to an island component argument becomes an empty objectI am passing `ReadableStream` to an island component argument becomes an empty objectdeno.jsonc "unstable" format?I added this entry to my `deno.jsonc`: ```json "unstable": [ "broadcast-channel", "ffi", "fs"Signal value not updating from inside of `for await of` loop inside of an IIFE```ts // routes/connect.tsx import type { FunctionComponent } from 'preact' import type { PageProps Pricing Question - Is my pro account applied to my Orgs?Just recently purchased a pro account cause I thought a project would benefit from the extra firepowRecommended `denoland/deno` contributor editor setupI have a problem with deno trying to redefine itself via random `declare namespace Deno { ... }` thrHow to enable "WebSocketStream" using deno.json fileI want to enable "WebSocketStream" using deno.json's "unstable" array option.subhosting to run user scriptsI want to allow users to run arbitrary scripts, but they don't need to be available as endpoints, soRemove Old DeploymentsIs there a way to remove old preview deployments, or do they expire at some point? There are a numbeCompiled program cannot write to fileI made a program that can download the latest version of papermc or velocity. and it does download iHow to monkey patch an installed third party deno module.Is it possible to monkey patch an installed third party deno module?? I want to overwrite a functionMongoDB connection error on Deno DeployHello, I've a project running on Deno Deploy using Deno Fresh and I need to write information beinDeno cron instrumentationWe at Sentry are looking at adding automatic instrumentation for Deno crons: https://github.com/getsWebgl2 in Deno i.e. for unit testingnodejs has this challenge that there is no way to run webgl2 (or webgpu), i.e. for unit testing. The"A fetch response body was created during the test" when invoking a PUT request in a test?I'm writing a Deno library for uploading files on IPFS. The code is very simple: ```ts export cons