Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to read a nonexistent KV entry results in null, where cloudflare workers throws an exception #62

Closed
Rysertio opened this issue Oct 8, 2021 · 2 comments

Comments

@Rysertio
Copy link

Rysertio commented Oct 8, 2021

The example bellow, when ran using miniflare main.js -k TEST_NAMESPACE1 returns null.

// main.js
addEventListener("fetch", (e) => {
  e.respondWith(
    TEST_NAMESPACE1.get("key").then((value) => new Response(value))
  );
});

But when uploaded to cloudflare workers with the KV binding, it throws an exception.
In order to get the null response in cloudflare workers, a key must be created with null value.

@Rysertio Rysertio changed the title Attempting to read a non-existent KV entry results in null, where cloudflare workers returns an exception Attempting to read a nonexistent KV entry results in null, where cloudflare workers returns an exception Oct 8, 2021
@Rysertio Rysertio changed the title Attempting to read a nonexistent KV entry results in null, where cloudflare workers returns an exception Attempting to read a nonexistent KV entry results in null, where cloudflare workers throws an exception Oct 8, 2021
@mrbbot
Copy link
Contributor

mrbbot commented Oct 8, 2021

Hey! 👋 Would you be able to share the exception that you're seeing? I've just tried this out using wrangler dev, and I'm getting null for non-existent keys which is consistent with the docs: https://developers.cloudflare.com/workers/runtime-apis/kv#reading-key-value-pairs.

@Rysertio
Copy link
Author

Rysertio commented Oct 8, 2021

Sorry, but it turns out the exception was due too trying too perform slice operations on null.

@Rysertio Rysertio closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants