oliver-oloughlin / kvdex

A high-level abstraction layer for Deno KV with zero third-party dependencies by default 🦕🗝️
https://jsr.io/@olli/kvdex
MIT License
192 stars 6 forks source link

OK flag always false on local install (Mac) yet code works on Deno Deploy. #121

Closed juliendorra closed 10 months ago

juliendorra commented 10 months ago

Using an outdated 1.32.3 local install will always set the ok flag to false. The operations themselves are executed, which makes it harder to find the source of the issue.

Maybe it would good to add a minimal version alert (or just a "always use the last Deno version") on the readme, as this is a non-obvious mode of failure.

Basic test code I used to ensure that it was indeed a purely flag issue:

import { kvdex, model, collection } from "https://deno.land/x/kvdex/mod.ts"

const kv = await Deno.openKv();

type Counter = {
    text: string
}

const CounterModel = model<Counter>()

const db = kvdex(kv, {
    counters: collection(CounterModel)
})

const deleteAll = await db.deleteAll()

console.log("deleteAll", deleteAll)

const set = await db.counters.set(
    "entry1",
    { text: "bobby set" }
)
console.log("set", set)

const write = await db.counters.write(
    "entry2",
    { text: "bobby written" }
)
console.log("write", write)

const add = await db.counters.add(
    { text: "bobby added" }
)
console.log("add", add)

const update = await db.counters.update(
    "entry1",
    { text: "bobby changed" }
)
console.log("update", update)

// console.log(add)
const list = await db.counters.getMany()

console.log(list)
oliver-oloughlin commented 10 months ago

I tried copying your code and running it, but I couldn't reproduce the issue. All the commit results had the ok flag set to true. Have you been able to investigate more or seen why the issue occurs for you locally?

oliver-oloughlin commented 10 months ago

Wait, I completely glossed over that you are using Deno 1.32. That's almost definitely what's causing the issue then. I will do some additional testing and add a notice of the minimal supported version as you suggested.


From: Julien Dorra @.> Sent: Friday, November 24, 2023 9:26:45 AM To: oliver-oloughlin/kvdex @.> Cc: Subscribed @.***> Subject: [oliver-oloughlin/kvdex] OK flag always false on local install (Mac) yet code works on Deno Deploy. (Issue #121)

Hi, I didn't manage to find why, but in my local tests (on Mac) the ok flag is always false. The operation themselves are executed.

On Deploy playgrounds the flags are returned as true properly.

Do you see a way that the local setting would do the operation properly but return {ok: false}?

— Reply to this email directly, view it on GitHubhttps://github.com/oliver-oloughlin/kvdex/issues/121, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AM4YH3CGMGTQLQRXNPDMOGLYGBK4LAVCNFSM6AAAAAA7YYRXRSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYDSMZQGYZDKMQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

oliver-oloughlin commented 10 months ago

Earliest working version of Deno is 1.37.0. Every version since then passes the tests. I have updated the README to make a notice of this.