Get Value does not return the latest value
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
I have this code:
// utils/storage.ts
const list = storage.defineItem<string[]>(
'local:list',
{
fallback: [],
},
);
export const store = {
list,
};
Somewhere in the onClick event button:
await store.list.removeValue();
const value = 'test';
let list = await store.list.getValue();
console.log(list);
list.push(value);
await store.list.setValue(list);
The console log:
[]
['test']
(2) ['test', 'test']
(3) ['test', 'test', 'test']
I expect to get this:
[]
[]
[]
Reproduction
Steps to reproduce
No response
System Info
System:
OS: macOS 15.4.1
CPU: (14) arm64 Apple M4 Pro
Memory: 754.11 MB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.16.0 - ~/.nvm/versions/node/v22.16.0/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v22.16.0/bin/npm
pnpm: 10.10.0 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 137.0.7151.120
Safari: 18.4
npmPackages:
wxt: ^0.20.6 => 0.20.7
Used Package Manager
npm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached wxt-example.zip and the storage definition in utils/storage.ts. Run the reproduction and trace the removeValue, getValue, and setValue calls from the onClick handler. Done means repeated clicks no longer accumulate prior list values and the observed output matches the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100