Git Product home page Git Product logo

Comments (33)

jcubic avatar jcubic commented on May 24, 2024 2

So this duplication of #1680 and #1446. This needs to be added to docs, that Buffer needs to be provided when using bundler.

@orangemug, sorry didn't notice that the issue was locked when I reopened it.

I'm changing the description to add docs about Buffer dependency.

The problem is that bundlers run in NodeJS that have the Buffer but it's not included with the bundler. I'm not sure if the library can do something with detecting Buffer other than replace it with Uint8Array.

from isomorphic-git.

orangemug avatar orangemug commented on May 24, 2024

Pinning the dependency to an older version "isomorphic-git": "1.24.5" seems to fix this issue for me.

from isomorphic-git.

jcubic avatar jcubic commented on May 24, 2024

@Artawower Can you create a working reproduction that I can run?

from isomorphic-git.

mojavelinux avatar mojavelinux commented on May 24, 2024

I ran the following code in Node.js and it seems to work just fine:

'use strict'

const git = require('isomorphic-git')
const http = require('isomorphic-git/http/node')
const fs = require('fs')
const dir = '/tmp/repo'

;(async () => {
 fs.rmSync(dir, { recursive: true, force: true })
 await git.clone({
   fs,
   http,
   dir,
   corsProxy: 'https://cors.isomorphic-git.org',
   url: 'https://github.com/isomorphic-git/lightning-fs',
   singleBranch: true,
   depth: 1,
 })
})()

I don't really have any experience using isomorphic-git in the browser, so I can't say if that works or not.

from isomorphic-git.

Artawower avatar Artawower commented on May 24, 2024

@Artawower Can you create a working reproduction that I can run?

https://github.com/Artawower/isomorphic-git-problem

from isomorphic-git.

jcubic avatar jcubic commented on May 24, 2024

@Artawower I run npm install and npm run dev and got an error:

Uncaught TypeError: Buffer2 is undefined

and warning:

Module "buffer" has been externalized for browser compatibility. Cannot access "buffer.Buffer" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

What do I need to do to run your code?

from isomorphic-git.

Artawower avatar Artawower commented on May 24, 2024

@Artawower I run npm install and npm run dev and got an error:

It's supposed to work, tested via 2 different machines
image

I don't think it's a code issue (there are no additional dependencies), have you tried commenting out imports from your library?

from isomorphic-git.

Artawower avatar Artawower commented on May 24, 2024

Try checking this repo, there is no vite there [email protected]:Artawower/isomorphic-test-2.git

from isomorphic-git.

jcubic avatar jcubic commented on May 24, 2024

Maybe add package-lock.json to the repo. You can also try to remove the lock file and install again to see if it will work.

Also what OS, Browser, NPM, and NodeJS version do you use? Maybe it matters.

Also, it looks like you use Bun for some reason. Please provide instructions on how to run your code.

from isomorphic-git.

mojavelinux avatar mojavelinux commented on May 24, 2024

Also what OS, Browser, NPM, and NodeJS version do you use? Maybe it matters.

FYI, these are stated in the description ;)

from isomorphic-git.

mojavelinux avatar mojavelinux commented on May 24, 2024

Please provide instructions on how to run your code.

Agreed. As an observer on this issue, I think the reproduction case is too complex. It needs to be simplified to isolate the problem with as little other things going on as possible. Otherwise, it could be caused by a plethora of other problems that have nothing to do with isomorphic-git.

from isomorphic-git.

Artawower avatar Artawower commented on May 24, 2024
  • Added.
  • OSX Sonoma 14.3, node 18.0.0
    Linux MacBook-Pro 6.6.3-411.asahi.fc39.aarch64+16k #1 SMP PREEMPT_DYNAMIC Tue Dec 19 10:21:20 UTC 2023 aarch64 GNU/Linux node v20.10.0, npm 10.3.0, any browser (I tested chrome/firefox/brave)
  • npm install && npm run dev or npm install && npm run start for the second repository

from isomorphic-git.

mojavelinux avatar mojavelinux commented on May 24, 2024

I couldn't get it to run either. I tried:

npm ci
npm run build
npm run preview

There are no instructions in this repository for how to actually start the application, so I was just guessing.

from isomorphic-git.

mojavelinux avatar mojavelinux commented on May 24, 2024

I just saw the comment about how to run it. Now I did:

rm -f package-lock.json
npm i
npm run dev

However, I get the error Jakub was getting in the browser:

Uncaught TypeError: Buffer2 is undefined

from isomorphic-git.

Artawower avatar Artawower commented on May 24, 2024

I just saw the comment about how to run it. Now I did:

rm -f package-lock.json
npm i
npm run dev

However, I get the error Jakub was getting in the browser:

Uncaught TypeError: Buffer2 is undefined

I already asked above, but have you tried commenting out the import from the isomorphic-git library?
Honestly it's hard for me to say anything about your error, but if you comment out the code related to the library and the project starts, then we can conclude that the problem is in the dependency. If not, it is in the environment. Unfortunately, I can't test your error.

Also, does this apply to both projects?

from isomorphic-git.

mojavelinux avatar mojavelinux commented on May 24, 2024

With Chrome, I get a different error:

Uncaught TypeError: Cannot read properties of undefined (reading 'from')

but have you tried commenting out the import from the isomorphic-git library?

Why in the world would we do that if the whole point is that you have having a problem with isomorphic-git?

Honestly, I think this issue needs to be closed with "insufficient test case". You're wasting the isomorphic-git maintainers' time trying to solve problems in your project. This is ridiculous.

from isomorphic-git.

Artawower avatar Artawower commented on May 24, 2024

You're wrong. I solved my problem in a different way, not using your library.
I was only trying to point out the problem in the open sorce project.

I gave you 2 different examples, with 2 different frameworks, only with your library as a dependency, and that's still not enough?

What's really ridiculous is that you got a bug in your own library and are trying to blame it on an insufficient example. 🥴

from isomorphic-git.

mojavelinux avatar mojavelinux commented on May 24, 2024

You most certainly did not provide a reproducible test case, so your assertion that there a bug in isomorphic-git is just unfounded. We went out of our way to try to run your project, which is simply not working. Jakub and I both know how to use JavaScript applications and neither of us could get it to run. Your accusations are baseless. Your insistence on criticizing the maintainers shows no good faith on your part and is clearly just and attempt to belittle us. If that's how you are going to behave, we don't want your help.

from isomorphic-git.

jcubic avatar jcubic commented on May 24, 2024

The second repository works and I get the error. It's weird because:

https://cors.isomorphic-git.org/github.com/artawower/orgnote-atom-one-dark/info/refs?service=git-upload-pack

return this data:

001e# service=git-upload-pack
0000015572261d0d8316cb2165ae7786f3f4fedea4bbc06a HEADmulti_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed allow-tip-sha1-in-want allow-reachable-sha1-in-want no-done symref=HEAD:refs/heads/master filter object-format=sha1 agent=git/github-84a1a651248e
003f72261d0d8316cb2165ae7786f3f4fedea4bbc06a refs/heads/master

So it can't be an empty response. I'm reoping the issue to figure this out.

from isomorphic-git.

jcubic avatar jcubic commented on May 24, 2024

What's weird is that clone in documentation works fine. The same this CodePen. Something needs to happen with Vite.

@Artawower But since I'm not that familiar with the internals of git (I only do CR and merge PR), if you want this to get fixed you need to debug this yourself, all PRs are welcome.

from isomorphic-git.

shiftyp avatar shiftyp commented on May 24, 2024

Just FYI, I solved this personally by adding this to my bundled index file after installing the buffer shim from NPM:

import { Buffer } from 'buffer'

// @ts-ignore
window.Buffer = Buffer;

from isomorphic-git.

shiftyp avatar shiftyp commented on May 24, 2024

While the above solved the buffer import it did not solve the empty response, as it seems like only the first line of the response is read. Debugging a bit the reader for the response itself only gives the first line before issuing done, so I'm unsure if it's a problem with Chrome or the library or a combination thereof. For chunked responses as I understand it Chrome should read the chunks of the content type isn't "text/plain" and it is correctly transmitted when cloning a repo as a service advertisement. The end result of this is an incomplete clone of the repository as it doesn't receive the full advertisement on clone. This happens for me both with my own setup and with the example in the docs

from isomorphic-git.

jcubic avatar jcubic commented on May 24, 2024

@shiftyp can you maybe create a production that we can test?

from isomorphic-git.

shiftyp avatar shiftyp commented on May 24, 2024

from isomorphic-git.

jcubic avatar jcubic commented on May 24, 2024

Awesome, thank you

from isomorphic-git.

shiftyp avatar shiftyp commented on May 24, 2024

So I wasn't able to reproduce it simply, and some debugging revealed a combination of bugs in my code that made realizing any one of them quite difficult. A comedy of errors if you will. Anyway, thanks it looks like my original solution to the issue is serviceable for the browser

from isomorphic-git.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.