storage
storage copied to clipboard
Setting key to undefined doesn't actually change it
Google search terms
extend-chrome setting undefined
Describe the bug
When setting a key in useBucket to undefined (or null), the value doesn't get changed. It resolves to the previous value instead. Removing the key works.
How do we reproduce?
This is my bucket
export interface StateValue {
sidePanelTabId: number | undefined
}
export const stateBucket = getBucket<StateValue>('EXTENSION_STATE')
When I set the value to undefined (in async context), the value does not change in the valueStream
stateBucket.valueStream.subscribe({sidePanelTabId} => {
console.log('stateBucket changed', obj) // First run: undefined, 2nd run: 1, 3rd run: 1, 4th run: undefined
})
stateBucket.set({sidePanelTabId: 1})
stateBucket.set({sidePanelTabId: undefined})
stateBucket.remove("sidePanelTabId")
Expected behavior
The third run should print undefined instead of 1.
Actual behavior
The third run prints the last value: 1
Screenshots
Please complete the following information:
- Library Version: "^1.5.0"
- Operating System: MacOS Sonoma 14.1.2 (23B92)
- Browser: Chrome
- Node Version: 18
Additional context
Run in the background script