vercel / vercel/storage

Vercel KV returns null on start of dev server in Nextjs

Open
#781 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
595
Forks
101
Avg merge
2h 24m
Merged PRs (30d)
1

Description

I'm using Vercel KV in my Nextjs app. Despite the key being available in the storage, I've noticed that the KV library returns null when I start the dev server. It returns correct data after that until I restart the server. When I restart, it again does the same thing. Here is the sample code:

import { kv } from '@vercel/kv';
const accessTokenData = await kv.get('accessTokenData'); 
console.log(accessTokenData); // <--- null on the first try, fetches correct data afterwards.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with the provided TypeScript entry point, kv.get('accessTokenData'), during a Next.js development-server restart. Compare the first read with later reads and inspect the storage library's startup and KV request path; done means the existing key is returned consistently from the first request.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.