Skip to content

KV without path will not persist data if compiled #24318

Open
@K0IN

Description

Version: Deno 1.44.4 (release, x86_64-pc-windows-msvc) (same behaviour on Linux)
v8 12.6.228.9
typescript 5.4.5

When compiling a script that uses DenoKv, it fails to persist data.

This can be fixed by supplying a path to Deno.openKv, which is bad since i need to change my script for the environment it would run in (deno run and deno deploy vs deno compile).

There might be similar issues, see:
#10693

minimal reproducible example:

const kv = await Deno.openKv(); // setting a persistant path, will store the data
const key = ["device", "key"];
await kv.set(key, "hi deno team.");
kv.close();

const kv2 = await Deno.openKv(); // setting a persistant path here, will read the data
const {value} = await kv2.get(key);
console.log(value); // Expected Output: hi deno team.
kv2.close();

Works fine

deno run --allow-all --unstable-kv main.ts

Does not work

deno compile --allow-all --unstable-kv -o main main.ts
./main

This is a bug, since from the Deno.openKv() I would assume that it would work without a path.
See: https://deno.land/[email protected]?s=Deno.openKv

I also tried setting --location on deno compile, but same issue.

Metadata

Assignees

Labels

bugSomething isn't working correctlycompilerelated to the `deno compile` featureext/kvRelated to "Deno.openKv()" API

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions