-
-
Notifications
You must be signed in to change notification settings - Fork 402
"TypeError: Cannot read property '0' of undefined" during clone using Parcel #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hmm... that's interesting. I haven't seen that error before! I don't have enough information to reproduce the error yet. What example are you running exactly? And what browser were you using? |
Thanks for getting back to me @wmhilton. Sorry I was tired last night after spending half a day trying to get this working and failed to give you all the information you need to help! I should have mentioned that I am using parcel.js (with babel configured for babel-preset-env) to bundle an index file which contains almost exactly what is in the browser tutorial. I have created a minimal gist that reproduces the issue
I am running:
|
Awesome! I'll investigate this today. I have a sneaking suspicion (given that adding a console.log "fixed" it) that it may be a bug in the transpiler (parcel, or babel, or uglify) but if I can reproduce it and figure out how to fix it without adding a console.log that'll be ideal! |
This is officially really weird. AFAICT it's probably a bug in parcel related to the infamous babel "regenerator-runtime". It seems to be transpiling my simple "for (h of hs)" loop into something else. I just can't figure out what. |
Aha. Firefox shows the actual error and the transpiled JS that parcel's created: Unhandled promise rejection TypeError: "_e10 is undefined" }, {
key: "parseHeaders",
value: function parseHeaders() {
var t = c.justHeaders(this._commit).split("\n"),
e = [];
var _iteratorNormalCompletion13 = true;
var _didIteratorError13 = false;
var _iteratorError13 = undefined;
try {
for (var _iterator13 = t[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
var _r7 = _step13.value;
" " === _r7[0] ? e[e.length - 1] += "\n" + _r7.slice(1) : e.push(_r7);
}
} catch (err) {
_didIteratorError13 = true;
_iteratorError13 = err;
} finally {
try {
if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
_iterator13.return();
}
} finally {
if (_didIteratorError13) {
throw _iteratorError13;
}
}
}
var r = {
parent: []
};
for (var _i2 = 0; _i2 < e.length; _i2++) {
/*HERE*/ var _t12 = _e10[_i2];
var _e10 = _t12.slice(0, _t12.indexOf(" ")),
_n4 = _t12.slice(_t12.indexOf(" ") + 1);
Array.isArray(r[_e10]) ? r[_e10].push(_n4) : r[_e10] = _n4;
}
return r.author && (r.author = Object(u.a)(r.author)), r.committer && (r.committer = Object(u.a)(r.committer)), r;
}
}, { Hmm. |
Well, you might not like this answer but I found one potential "solution". Problem goes away if you add this to your "browserslist": [
"last 2 Chrome versions"
] With some experimenting, I found even this works if you want to be more conservative: "browserslist": [
"> 3%"
] Parcel defaults to I know this is not super satisfying - I too am now curious what I did that causes Babel (or something) to lose track of the scope of |
I'm renaming the issue to make it more Googleable. I doubt you'll be the last person to run into this weird error. |
Awesome. Thanks for your help @wmhilton Your solution works well and is fine for my needs. |
I am following the browser example and I get an error on this line in
GitCommit
If I npm link a clone of the
isomorphic-git
repo and log out the headers variable it is an array of strings. Have I stumbled on a bug?These are the headers:
adding a console.log statement inside the loop over the normalised headers and the problem goes away ¯\_(ツ)_/¯
The text was updated successfully, but these errors were encountered: