suchipi / fs-remote

📡 Drop-in replacement for fs that lets you write to the filesystem from the browser
MIT License
231 stars 7 forks source link

Error on using with isomorphic-git #2

Closed arjunattam closed 5 years ago

arjunattam commented 5 years ago

Thank you for this plugin, love the simplicity of the API.

I've been unable to use it with isomorphic-git - and I would really appreciate any pointers that you might have for me. This is the stack trace:

TypeError: Cannot read property 'serialize' of undefined
    at eval (tuple.js:28)
    at Array.map (<anonymous>)
    at Object.serialize (tuple.js:27)
    at Object.serialize (decorateTypeDef.js:15)
    at Object.serialize (union.js:33)
    at Object.serialize (decorateTypeDef.js:15)
    at Object.writeFile (client.js:36)
    at P (index.js:32)
    at new Promise (<anonymous>)
    at FileSystem.eval (index.js:6)

Running a plain fs.writeFileSync() worked, so I'm guessing the server-client setup is in order. The isomorphic-git lib also works with browserFS, so I'm guessing there's something different about this that you could shed some light on. This is a relevant docs link. Attaching my code snippet below:

import * as git from "isomorphic-git";

const createClient = require("fs-remote/createClient");

export const init = () => {
  const fs = createClient("http://localhost:3000");
  git.plugins.set("fs", fs);

  git
    .clone({
      dir: "test-repo",
      corsProxy: "https://cors.isomorphic-git.org",
      url: "https://github.com/karigari/really-large-repo",
      singleBranch: true,
      depth: 1
    })
    .then(r => console.log("done", r))
    .catch(e => console.log("error", e));
};

Happy to provide any info that you might need to debug this.

suchipi commented 5 years ago

Hello, thank you for the report!

I looked into it and it's a bug with how I'm handling the input arguments to fs methods. I'm fixing it and will let you know when it's fixed.

suchipi commented 5 years ago

Okay, this should be fixed in fs-remote 0.1.9. Please update your dependency and try again.

arjunattam commented 5 years ago

Amazing, thanks so much! Works for me now