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

Cannot use fs for session storage #84

@ryoji-yamauchi-blc

Description

@ryoji-yamauchi-blc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions