Two bugs: Shared file bug "process cannot access the file". Files still accessed after being deleted

So, I have a plugin that in short creates renditions and is doing some read and writes using xd-helper-storage.
The problem i’m facing is that with the 100% untouched exact same code and exact XD document but just with someone shared I start getting this error:

[Error: HRESULT: -2147024864, The process cannot access the file because it is being used by another process.

The second issue I’m facing is that I have some local config stored for my plugin using xd-helper-storage. To confirm this bug i opened the storage.json file myself to see wether the data was being deleted or not. The locally stored data was indeed deleted as inteneded on a button onClick event but i have to refresh the plugin in-order see those changes. XD keeps acting like the data is still there. More like it’s using cached? files.
If i can programatically refresh the plugin that would be fine too.

First issue - this is a new problem I haven’t seen since document sharing became available. @afuchs are you aware of this and do we have any best practices in case the document is shared with others?

Second issue - could you maybe workaround by modifying the json file instead of deleting it totally?

1 Like

Second issue: I’m just deleting the json data not the whole file. So, in the end an empty object is left.
I’ll attach an video just in a bit so it’s more clear to see both problems.

Just to make sure: I’m assuming you mean xd-storage-helper (a library I’ve developed)?

If so:

Yes, I do have a sort of caching system implemented in the helper. The json file mustn’t get modified from “outside” for the helper to work. The thing is that when I first load the data, I have it as a variable and don’t make any more “reading” file-accesses to the storage.json (to optimize performance). Instead, all updates have to get done via xd-storage-helper, in which case, it updates its “cached” variable and the file.

When you then reoload the plugins, this variable (the cached storage.json) is gone, the storage helper re-initializes itself and reads the file, once again.

The use-case for the helper is defined as

[…] make storing key-value-pairs (e.g. settings) for plugins for Adobe XD CC easier.

it basically covers for the missing localStorage in plugins. To make the file empty, again, you can use

await storageHelper.reset();

or, to delete a single key:

await storageHelper.delete(key)

I hope this at least clarifies the reason of the second issue (and potential solutions). Regarding the first issue: This appears to be something on XD’s side, which is why we have to keep an eye out about that together.

In the hope that this helps,
If you have any further questions regarding the library, don’t be afraid to ask,
Happy coding :nerd_face:,


What file is it that you’re trying to read or write when you get that “used by another process” error? Where’s the file located?

When you say “with someone shared” do you mean you’ve used the “Invite to Document” button in the upper-right to grant access to another XD user? If so did you click the button at the bottom of that popup to “Enable Coediting,” or no?

Issue 2:
The details about caching helped a lot and i was able to fix the issue with introducing another useEffect() for handling cached and re-validating.Thank you. I’m still looking into the first issue.

1 Like

I have messaged you.

as for issue number 1: I think it may be related to xd-helper-storage but mostly fs module of XD.
I keep coming across this error:

[Error: HRESULT: -2147024864, The process cannot access the file because it is being used by another process.

After this error, my storage.json seems to get totoally wiped of all data without me running reset() or delete.
I’m not sure how this is happening though because all the read/write operations are a sync with async/await. Any ideas what this error might be exactly and if there’s a way i can find out what file is it saying is being used by another process?

I’m also able to get the error without sharing on.
If only i can get which file is being used by what process i can further troubleshoot as it’s a fairly large codebase and lots of read/writes are happening but all of these operations are happening with async/await in a sync manner.