sindresorhus / electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
MIT License
4.57k stars 148 forks source link

Uncaught Exception: TypeError`Use delete() ` to clear values at ElectronStore.set #255

Closed 2811267153 closed 1 year ago

2811267153 commented 1 year ago

image Hello, I'm sorry to bother you. I found an error when I was using this library today. As you can see in the specific error report, I want to save the user's historical music listening data in the main process, but, because I don't Determine whether the user has generated historical data before, so I need to delete the content saved by this parameter first, and then regenerate new content, but this error will appear when writing new data. I am not sure How did this problem arise, hope you can help me image

sindresorhus commented 1 year ago

You need to use the delete() method, not the delete keyword.

2811267153 commented 1 year ago

In fact, I used thedelete()method at the beginning, but it still reported an error, which is why I used the delete keyword, but it still reported an error image

I encountered this exception twice last night. The first time was because I had a problem storing the data in songHistoryListData. I thought it was because the data I stored was too large, so I put it in my debugging code first. After clearing the list and storing the data, there is no error, but the list should be empty now, I don't know how this exception is triggered,

Coldplayer1995 commented 1 year ago

This should not be closed had the same issue, and this is happening also when you try to set undefined value.

arepp23 commented 1 year ago

+1 this happens when you try to set a boolean false value

zprjk commented 9 months ago

This should not be closed had the same issue, and this is happening also when you try to set undefined value.

I got the same problem. Had to add a safeguard but the error makes sense since electron-store uses json to store data, undefined is not a valid syntax in JSON. The error output mentioned above didn't help tho.