D
Deno

help

Getting values from Deno KV in a Web Worker always return empty array despite working correctly o...

Aataractic8/30/2023
Getting values from Deno KV in a Web Worker always return empty array despite working correctly outside the worker context (in the parent app). What can cause this behavior?
No description
Ffro.profesional8/31/2023
Hmmm its reading from same db right? 🤔
Aataractic8/31/2023
yes
ABAltair 680b8/31/2023
What does getAllJobs() look like?
Aataractic8/31/2023
export async function getAllJobs() {
return await getValues<Job>({ prefix: ["jobs"] });
}
export async function getAllJobs() {
return await getValues<Job>({ prefix: ["jobs"] });
}
ABAltair 680b8/31/2023
I don't think I can help. I don't know what getValues<job> does. I assume at some point it's calling kv.list? Is the code in a public repo? Can we have a look?
Aataractic8/31/2023
yes sorry, here is getValues()
async function getValues<T>(
selector: Deno.KvListSelector,
options?: Deno.KvListOptions,
) {
const values = [];
const iter = kv.list<T>(selector, options);
for await (const { value } of iter) values.push(value);
return values;
}
async function getValues<T>(
selector: Deno.KvListSelector,
options?: Deno.KvListOptions,
) {
const values = [];
const iter = kv.list<T>(selector, options);
for await (const { value } of iter) values.push(value);
return values;
}
i use a lot of code from saaskit to help me
ABAltair 680b8/31/2023
I have no experience with saaskit; sorry. Hopefully someone with experience will jump in to help you.
Aataractic8/31/2023
thanks you for trying :)
Ccknight9/1/2023
Have you tried Deno.openKv() in your worker?
Ffro.profesional9/2/2023
That will create another db
Iiuioiua9/3/2023
Sidenote: I'd actually recommend instead using collectValues(). It allows you to use iter.cursor once the values are collected.
Aataractic9/3/2023
i will do it once it can at least work, thanks for the tip! i went with another approach, using message events to send job data both ways between the main thread to the worker, and it works! however i'm pretty sure it impacts performance pretty badly as compared to the first idea.
Iiuioiua9/3/2023
Actually, check SaaSKit out once v1 is released. We’ll have some noteworthy bits of the KV implementation worth looking at 👀
Aataractic9/3/2023
sure!

Looking for more? Join the community!

Recommended Posts
Simple Deno program on Windows quits after 20 secondsHi I have created a simple deno program and now compiled to an exe file for window using the commanNeed some help for Deno/FreshJS projectI have a Deno/FreshJS project and need some help from someone with extensive experience in Deno/FresI need more help understanding imports and relative paths for a module I am writingI am diving into the world of Deno and I am trying to port an existing node CLI. _If you are develIs there an idiomatic/common/modern way of creating a queue of jobs to be executed one after anot...Is there an idiomatic/common/modern way of creating a queue of jobs to be executed one after anotherLaunch tests with unstable flag inside VS CodeHi there, I'm creating a module that uses FFI and Deno.dlopen and I wrote tests to validate some of What is the difference between JS Map and JS Object?I know that `Map` is hash table implementation for JS, but how does it differ from an object? With rDeno KV: Should I expect 'value too large' errors inserting a JSON file with kv.set?I was trying out kv and quickly ran into something I found surprising; ```js let kv = await Deno.oDeno language server stops working in VS CodeAfter some random time the language server stops working and I suddenly get code errors like this: `Getting free disk space without using child_process.Hello everyone! I would like to create a small CLI tool using Typescript and Deno. I would like to mtest --filter a stepCan I only run a certain step in the test?fastwebsockets how to end client calls and avoid Error in websocket connection Unexpected EOFWhat is the issue in this client code that causes the error? ```rust pub async fn connect() -> Resuldeno compile --include argumentIn `deno compile`, how can i include a whole directory instead of just a file? Also, is there a way `deno run` as a library`deno run` does a lot of useful things behind the scenes, many of which are not exposed as a libraryPermissions with npm/node importsI'm trying to run a command and it's like I need to add `--allow-read` permissions because of the `nBroadcastChannelWhen using BroadcastChannel api, in the background does deno send the broadcast to every instance orIs it possible to create a TCP server on Deno Deploy?Is it possible to create a TCP server on Deno Deploy?oak server can't accept requests from another server?hi, I'm trying out deno with oak to make a simple server. I set up cors(x/cors), it accepts requestsaddEventListener for keydown in terminal via deno?Is there something like `addEventlistener("keydown")` in deno, so i can capture terminal inputs?Deno KV Type ErrorWhen I run await (await kv.get<typeThing>(["example"])).id (the value is an object), it returns a tyHow to improve seo ?https://deno.land/x/blog My question is when you use tool like this that work with md, how can i do