jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.06k stars 216 forks source link

IndexedDB options is undefined by default. TypeError: Cannot read properties of undefined (reading 'storeName') #336

Closed milahu closed 1 year ago

milahu commented 1 year ago

IndexedDB options should default to {}

bad: options is undefined

  let fs;
  BrowserFS.configure({
    fs: "MountableFileSystem",
    options: {
      "/": { fs: "IndexedDB" }, // bad
      // TypeError: Cannot read properties of undefined (reading 'storeName') 
    },
  }, (error) => { if (error) { throw error; } fs = require("fs"); });

workaround: set options to {}

  let fs;
  BrowserFS.configure({
    fs: "MountableFileSystem",
    options: {
      "/": { fs: "IndexedDB", options: {} }, // workaround
    },
  }, (error) => { if (error) { throw error; } fs = require("fs"); });
NovaAndrom3da commented 1 year ago

I would also set options.storeName to a unique name for the name of the IndexedDB itself, as that fixed the error for me, as a workaround.