Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Cannot use fs for session storage #84

Open
ryoji-yamauchi-blc opened this issue Jul 19, 2023 · 1 comment · May be fixed by #85
Open

Cannot use fs for session storage #84

ryoji-yamauchi-blc opened this issue Jul 19, 2023 · 1 comment · May be fixed by #85
Labels
bug Something isn't working

Comments

@ryoji-yamauchi-blc
Copy link

Environment


  • Operating System: Darwin
  • Node Version: v18.16.1
  • Nuxt Version: 3.6.3
  • Nitro Version: 2.5.2
  • Package Manager: npm@9.5.1
  • Builder: vite
  • User Config: devtools, modules, session
  • Runtime Modules: @sidebase/nuxt-session@0.2.7
  • Build Modules: -

Reproduction

https://github.com/ryoji-yamauchi-blc/nuxt-session-playground

npm install && npm run dev

 ERROR  [worker reload] [worker init] Cannot add property ignore, object is not extensible     5:01:26 PM

  at node_modules/unstorage/drivers/fs.mjs:20:17
  at .nuxt/dev/index.mjs:713:16
  at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Describe the bug

If fs is specified for session storage in nuxt.config.js, an error occurs.

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: ["@sidebase/nuxt-session"],
  session: {
    session: {
      storageOptions: {
        driver: "fs",
        options: {
          base: "./data",
        },
      },
    },
  },
});

The cause is that the unstroage fs driver is updating the config returned by useRuntimeConfig.
The config returned by useRuntimeConfig looks like Object.preventExtensions is set and cannot be updated.
I could not read from the nuxt source code where it is set.

https://github.com/unjs/unstorage/blob/main/src/drivers/fs.ts#L32

Additional context

No response

Logs

No response

@ryoji-yamauchi-blc ryoji-yamauchi-blc added the bug Something isn't working label Jul 19, 2023
@ryoji-yamauchi-blc ryoji-yamauchi-blc linked a pull request Jul 19, 2023 that will close this issue
4 tasks
@gbalcewicz
Copy link

This also should be fixed on the unstorage side, the driver should not modify the options object:
unjs/unstorage#274

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants