Skip to content

Setting key to undefined doesn't actually change it #29

@Kitenite

Description

@Kitenite

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions