node-keytar icon indicating copy to clipboard operation
node-keytar copied to clipboard

Error with setPassword: The specified item already exists in the keychain.

Open adeperio opened this issue 7 years ago • 3 comments

Hi

I am on node-keytar 4.2.1. Every so often, when I call setPassword, keytar sends back the following exception:

The specified item already exists in the keychain.

According to the docs I was expecting this function to update an existing item, or create a new keychain item if one doesn't exist. Is this the correct assumption? If so any ideas why I might be seeing this error.

Happens on some calls to setPassword, but on other calls it doesn't.

adeperio avatar Sep 28 '18 05:09 adeperio

@adeperio which OS are you testing on?

shiftkey avatar Jan 21 '19 18:01 shiftkey

I've seen reports of this as well, on macOS 10.14.6. Is there any data I can collect to help diagnose the problem?

RMacfarlane avatar Mar 31 '20 23:03 RMacfarlane

Actually, I think I now understand what is happening in my case! I have several different processes that are reading and writing to the same keychain item. If writes occur pretty much simultaneously, then one will throw the duplicate item error during the second AddPassword here: https://github.com/atom/node-keytar/blob/3c232b5f58f84b590ecf068a5251bbe268739e15/src/keytar_mac.cc#L81-L99

RMacfarlane avatar Apr 02 '20 00:04 RMacfarlane