Pull crashes Node, cannot be caught using try-catch
See original GitHub issueHey, pull
brings Node down for me in the TypeScript repro below:
import * as git from 'isomorphic-git';
import * as fs from 'fs-extra';
import * as readline from 'readline';
void async function() {
console.log('Removing…');
await fs.remove('junk');
console.log('Removed.');
let errored = false;
try {
console.log('Cloning…');
await git.clone({ fs, dir: 'junk', ref: 'master', url: 'https://github.com/TomasHubelbauer/bloggo.git' });
console.log('Cloned.');
} catch (error) {
console.log('Failed to clone:', error);
errored = true;
}
try {
console.log('Pulling…');
await git.pull({ fs, dir: 'junk', ref: 'master' });
console.log('Pulled.');
} catch (error) {
console.log('Failed to pull:', error);
errored = true;
}
// Added to prove the process will end without any user interaction
!errored && await new Promise(resolve => {
readline.createInterface(process.stdin, process.stdout).question('Blocking…', (answer) => resolve(answer));
});
}()
Here’s the full output:
Removing…
Removed.
Cloning…
Cloned.
Pulling…
Using ref=master
I am using Node v9.4.0
, Isomorphic Git version "0.9.0"
and FS Extra version "5.0.0"
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Understanding Try/Catch and Domains for Error Handling in ...
Looking at JugglingDB, and trying to connect to a non-existent mysql server on my laptop, I do get ECONNREFUSED , but it's only...
Read more >When Try-Catch Doesn't Catch Errors in Node.js |
To demonstrate this problem, I will use Node.js streams: Stream is a structure that allows users to read/write data sequentially from/to it.
Read more >Exceptions and debugging - Advanced R. - Hadley Wickham
Condition handling tools, like withCallingHandlers() , tryCatch() , and try() allow you to take specific actions when a condition occurs. For example, if...
Read more >A Comprehensive Guide To Error Handling In Node.js
When you throw an error, it becomes an exception and needs to be caught somewhere up the stack using a try/catch block.
Read more >Error handling with promises - The Modern JavaScript Tutorial
catch at the end to handle errors in all of them. In a regular try..catch we can analyze the error and maybe rethrow...
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
Since this is (hopefully?) a super rare edge case with corrupt git repositories, I’m going to close it and hope it doesn’t happen again. 😁 But if it does, we’ll have to address it because it was quite a serious crash.
Oooh, this is really interesting. I’m not using TypeScript, but can get the same error using plain JS and node v9.6.1:
Here is the output… interestingly I get an error during
clone
before it crashes:BUT! if I change the url from https://github.com/TomasHubelbauer/bloggo.git to https://github.com/isomorphic-git/isomorphic-git.git then it doesn’t crash. And (if anyone wonders) cloning bloggo with canonical
git
does not crash.The plot thickens! If I clone
greenkeeper/initial
instead ofmaster
it still crashes… but I don’t get theFailed to clone: Error: Unexpected object type commit found in tree for 'junk'
. (In case I need the commits to track this down…greenkeeper/initial
is currently at a96fc839d667e7c03de7cc98dc0d5a9530bd5bbc andmaster
is currently at 159af9ed895d49d09af27a6c6b0457961cde3042.)It’s also not the use of
fs-extra
which was my first thought. Does the exact same behavior with regularfs
.Investigation status: To Be Continued…