Comments (33)
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.
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.
Do you want to write documentation? I think there are no docs for use with bundlers.
from isomorphic-git.
Sure. I will probably do it next week.
from isomorphic-git.
Pinning the dependency to an older version "isomorphic-git": "1.24.5"
seems to fix this issue for me.
from isomorphic-git.
@Artawower Can you create a working reproduction that I can run?
from isomorphic-git.
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 Can you create a working reproduction that I can run?
https://github.com/Artawower/isomorphic-git-problem
from isomorphic-git.
@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 I run npm install and npm run dev and got an error:
It's supposed to work, tested via 2 different machines
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.
Try checking this repo, there is no vite there [email protected]:Artawower/isomorphic-test-2.git
from isomorphic-git.
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.
Also what OS, Browser, NPM, and NodeJS version do you use? Maybe it matters.
FYI, these are stated in the description ;)
from isomorphic-git.
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.
- 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
ornpm install && npm run start
for the second repository
from isomorphic-git.
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.
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.
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.
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.
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.
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.
The second repository works and I get the error. It's weird because:
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.
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.
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.
@shiftyp can you maybe create a production that we can test?
from isomorphic-git.
from isomorphic-git.
Awesome, thank you
from isomorphic-git.
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.
I had the same issue some days ago. I had to import from unpkg like this
import "https://unpkg.com/[email protected]";
Instead of importing the package from node_modules
And declare it in global like this to avoid ts errors:
declare global {
const git: typeof import("isomorphic-git");
}
Still no another workaround for this? I think its something declared globally that bundlers ignore
from isomorphic-git.
@lsegurado can you create a reproduction of the issue?
from isomorphic-git.
@jcubic Yep. Here you have https://github.com/lsegurado/isomorphic-bug
Just clone it, run npm install and npm run start. You will see the exception on screen
from isomorphic-git.
@lsegurado So the error in your case happened because Buffer
is missing. The error is misleading. The error is swallowed and a new error is thrown in a different part of the code.
This is something that can be improved to throw proper errors about a missing Buffer.
When using a bundler you need to set it up to include Buffer
dependency.
from isomorphic-git.
I think this should be on the docs or re-export on a /web including the dependency.
from isomorphic-git.
Related Issues (20)
- Tests are failing on Android HOT 15
- Cloning empty repository fails if git server uses git >= 2.41.0 HOT 5
- Getting a 404 with azure devops HOT 1
- not respecting server capabilities ( report-status ) HOT 1
- How can I abort a push operation on Node? AbortController seems to be not supported. HOT 2
- Codespell workflow needs approval
- Disable failing test that require credentials on Azure DevOps HOT 14
- Race condition makes it possible for a ref to be resolved to an empty string while it's in the middle of being updated HOT 16
- Invalid refs should throw HOT 11
- Isomorphic git functionality is broken on any browser
- Error Running Linter on main locally HOT 4
- Github Clone Broken on Latest Version HOT 6
- Pushing an annotated tag has slightly different behavior between isomorphic-git and Git HOT 1
- StatusMatrix results are different on Windows and Linux HOT 2
- Unchanged image/audio files being queued for commit with `git.add()` HOT 3
- BrowserFS deprecated HOT 7
- Detect streaming process HOT 6
- Tests are failing HOT 1
- `git.init()` with `gitdir` set behaves differently to `git init --separate-git-dir=foo`
- Equivalent to `git config --list` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isomorphic-git.