Sometimes it is not possible to read the tree property with readObject after git clone.
See original GitHub issueMy mention:
- Browser(Google Chrome v68)
- isomorphic-git@0.35.1
- IndexedDB
Because I can not use English much, I am using a translation machine.
Sometimes it is not possible to read the tree property with readObject after git clone.
I tried it with the following sample.
I opened the chrome developer tool and initialized with Application from Clear Storage.
After that, I ran init, created a directory and git cloned.
Finally, an error occurred when 10 tree objects were git logged and readObjected.
However, reloading the browser after git clone did not cause an error.
Is there any way to solve this problem?
sample html file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://isomorphic-git.org/js/browserfs.js"></script>
<script src="https://isomorphic-git.org/js/pify.js"></script>
<script src="https://unpkg.com/isomorphic-git"></script>
</head>
<body>
<p>case1: clear site data → init → mkdir → clone1 → log (ng)</p>
<p>case2: case1 → reload browser → init → log (ok)</p>
<p>case3: clear site data → init → mkdir → clone1 → init → log (ng)</p>
<p>case4: case2 → fsGetRootFsEmpty → mkdir → clone2 → log (ng)</p>
<script>
function init (params) {
let fsOptions = {
fs: 'IndexedDB',
options: {}
}
BrowserFS.configure(fsOptions, function (err) {
if (err) return console.log(err)
window.fs = BrowserFS.BFSRequire('fs')
// Initialize isomorphic-git with our new file system
git.plugins.set('fs', fs)
// make a Promisified version for convenience
window.pfs = pify(fs)
console.log('finish initializing')
})
}
async function clone (dir, url) {
await git.clone({
dir,
corsProxy: 'https://cors.isomorphic-git.org',
url: url
})
console.log('done')
}
async function log (dir) {
let log = await git.log({
dir,
depth: 10
})
await readObject(dir, log)
}
async function readObject(dir, log) {
for (const { oid, tree } of log) {
let blobs = await git.readObject({
dir,
oid: tree,
})
console.log({ oid }, { tree }, blobs.object)
}
}
async function mkdir (dir) {
let res = await pfs.mkdir(dir)
console.log('done')
}
async function readdir (dir) {
let res = await pfs.readdir(dir)
console.log(res)
}
async function fsGetRootFsEmpty() {
await fs.getRootFS().empty()
console.log('done')
}
</script>
<button onclick="init()">init</button>
<button onclick="clone('tutorial', 'https://github.com/tomatoaiu/vue-parcel-pack.git')">clone 1</button>
<button onclick="clone('tutorial', 'https://github.com/tomatoaiu/vue-vuex-counter.git')">clone 2</button>
<button onclick="log('tutorial')">log</button>
<button onclick="mkdir('tutorial')">mkdir</button>
<button onclick="readdir('tutorial')">readdir</button>
<button onclick="fsGetRootFsEmpty()">fsGetRootFsEmpty</button>
</body>
</html>
error
Uncaught (in promise) u: An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: GitTree: Error parsing buffer at byte location 0: Could not find the next space character.
at https://unpkg.com/isomorphic-git@0.35.1/dist/bundle.umd.min.js:8:28437
at new a (https://unpkg.com/isomorphic-git@0.35.1/dist/bundle.umd.min.js:8:28955)
at Function.from (https://unpkg.com/isomorphic-git@0.35.1/dist/bundle.umd.min.js:8:29142)
at Module.<anonymous> (https://unpkg.com/isomorphic-git@0.35.1/dist/bundle.umd.min.js:8:286250)
at Generator.next (<anonymous>)
at n (https://unpkg.com/isomorphic-git@0.35.1/dist/bundle.umd.min.js:8:285413)
at https://unpkg.com/isomorphic-git@0.35.1/dist/bundle.umd.min.js:8:285507
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
GIT fatal: failed to read object - Stack Overflow
First of all the problem, your facing is corrupted git repository. It's something odd that many can face, one of the reason when...
Read more >readObject sometimes hangs after fetch retrieves updates #654
If a repository is cloned and subsequently fetched using isomorphic-git, and the fetch pulled down updates, the next call to readObject ...
Read more >3 Ways To Access Object Properties in JavaScript
You can access an object property in JavaScript in 3 ways: dot property accessor, ... But sometimes properties are not valid identifiers:.
Read more >NAME - Git - gitrepository-layout Documentation
A Git repository comes in two different flavours: a .git directory at the root of the working tree;. a <project>.git directory ...
Read more >Write yourself a Git!
When all is done, we just call the correct constructor for that object's format. def object_read(repo, sha): """Read object object_id from Git repository...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🎉 This issue has been resolved in version 0.35.2 🎉
The release is available on:
Your semantic-release bot 📦🚀
Thank you! I have heard about this problem before, but have never been able to reproduce this! This is very helpful.
I understand the problem now! I do not know the solution yet, but I will solve this problem.