atomicdata-dev / atomic-data-browser

This repo is no longer used! Code is moved to Atomic-Server
https://github.com/atomicdata-dev/atomic-server/issues
MIT License
55 stars 9 forks source link

`getResourceAsync` Race condition returning a still loading resource #309

Closed adileo closed 1 year ago

adileo commented 1 year ago

While I was working on #75 I needed a way to recursively get the parents of a resource. I tried to create a new hook backed by recursive calls to getResourceAsync.

I noticed that getResourceAsync in store.ts suffers from a race condition happening when resource x is called by getResourceLoading(x) and, while it's still loading, you call getResourceAsync(x) it will return a unready resource. I suppose this is not the intended behaviour.

Opening a pull request with the fix

joepio commented 1 year ago

Fixed by @adileo! Thanks :)