Skip to content

Removing an app store during a store refresh leaves it in the App Store for up to an hour #622

Closed

Description

@nixfred

What happens

registry() in omarchyd/apps.mjs (about line 960) walks state.stores, syncs and loads each store in turn, and only at the end stores the finished list in registryCache. appStore.removeRepository removes the store from state.stores, deletes its folder and sets registryCache = null, but nothing stops a refresh that is already running. The refresh has already loaded the removed store into its local list, and when it finishes (after the slower stores that come later in the loop) it writes the cache:

registryCache = {at: Date.now(), list}   // list still contains the removed store

Until the cache expires (60 minutes) or something refreshes again, the removed store and all its apps are still shown in the App Store. Its folder is gone, so installing one of them is accepted (apps.install returns true) and the app then shows the error ENOENT: no such file or directory, lstat '.../apps/stores/<id>/<app>'.

The same window exists for any slow sync, for example one GitHub store taking tens of seconds while the user removes another store on the Stores settings page.

How to reproduce

createApps called directly on a throwaway data dir, two real local git stores (file://), every git call delayed by 150 ms (async, like the real execFile):

await add(storeA); await add(storeB)
await Promise.all([
  P('appStore.refresh'),
  (async () => { await sleep(600); return P('appStore.removeRepository', {url: storeA}) })(),
])

Result, 12 of 12 runs (removal at 500, 600 and 700 ms): both calls succeed, appStore.repositories and apps.json list only store B, apps/stores/ holds only B's folder, but appStore.registry still returns both stores. Then apps.install {appId:'aa'} returns true and the app is listed with the ENOENT text above as its error.

Expected: after the removal succeeds, the removed store is no longer returned by appStore.registry and its apps cannot be installed.

Suggested fix

Have registry() drop stores that are no longer in state.stores before it caches the list (or bump a generation counter in removeRepository and skip the cache write if it changed during the refresh).

Environment

Omarchy Server main (6aa7f7d, 0.9.52), Node 26.

Activity

  1. calledtoconstruct commented on Nov 20, 2026

    @calledtoconstruct
    Collaborator

    Tracked on the checklist in #701. This report stays open for its own reproduction.

    Posted by Grok 4.7 via Grok Build.

  2. added a commit that references this issue on Nov 21, 2026
    fc62d71
  3. calledtoconstruct commented on Nov 21, 2026

    @calledtoconstruct
    Collaborator

    Thank you @nixfred. A store removed while its refresh is still running is dropped before the registry is cached, and its folder is removed. This is on main in #858.

    🤖 Generated with Grok 4.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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