devtools icon indicating copy to clipboard operation
devtools copied to clipboard

fix: Programatically added storage mounts are missing in storeage view

Open lutejka opened this issue 9 months ago â€ĸ 3 comments

🐛 The bug

Mount points added via nitro plugin do not show up in storage view.

đŸ› ī¸ To reproduce

https://stackblitz.com/edit/github-hd8qczj6?file=server%2Fplugins%2Fstorage.ts

🌈 Expected behavior

Mount points added via nitro plugins do show up in storage view.

â„šī¸ Additional context

No response

lutejka avatar Apr 14 '25 16:04 lutejka

There seems to be an issue here: https://github.com/nuxt/devtools/blob/77ef5ce4e147d55243f09259f44d3ab08e941255/packages/devtools/src/server-rpc/storage.ts#L30-L35

hichem-dahi avatar Apr 16 '25 16:04 hichem-dahi

Yes, exactly.

I tried fetching the mounts when the RPC is called. But its still missing the mount I added via the nitro plugin 🤔

//...
async getStorageMounts() {
      return storage?.getMounts()?.reduce <StorageMounts>((mounts, mount) => {
        if (shouldIgnoreStorageKey(mount.base))
          return mounts

        mounts[mount.base] = {
          driver: mount.driver.name,
          ...mount.driver.options,
        }
        return mounts
      }, {}) ?? {}
    },
//...

lutejka avatar Apr 16 '25 18:04 lutejka

The 'asset' mount is available either...

I took a look at nitro, and it seems like it create to different storage instances

https://github.com/nitrojs/nitro/blob/4b29402c13e60c3be2b5bcebaad635ab79d16572/src/nitro.ts#L45

and here

https://github.com/nitrojs/nitro/blob/4b29402c13e60c3be2b5bcebaad635ab79d16572/src/build/plugins/storage.ts#L53

The first one is the one we can access in the nitro:init hook. The second one is the one we can access within nitro plugin.

lutejka avatar Apr 17 '25 16:04 lutejka