OverviewFilesCommitsIssuesDocsReleasesPeers

pear-git commits / e16aac4

Add P2P connectivity check before git clone in pgh app install
git ls-remote (lightweight, ~1KB) verifies the punch:// server is reachable before attempting the full git clone. If P2P is unreachable (timeout, crash, wrong peer), skips directly to HTTP archive fallback instead of waiting for the clone to fail. 20-second timeout on the ping — fast enough to not delay installs, long enough for DHT discovery + holepunch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e16aac4f7090c2e2d4f67da7c27ea7058837e88f
by plankatron <fleeky@gmail.com> · 2026-04-07T13:17:39.000Z

Changed files (1) +25 -11

lib/cli/commands/app.js +25 -11
……@@ -223,19 +223,33 @@ async function appInstallGit (repoName, flags) {
223223
224224 // P2P git clone first (gives OTA updates via PearGitUpdater)
225225 if (cloneUrl) {
226 if (flags.force) cleanup(installDir)
227
228 log('Cloning ' + repoName + ' (release branch) from ' + cloneUrl + '...')
229
226 // Connectivity check: ls-remote is lightweight (~1KB) and fast.
227 // If the P2P transport can't reach the server, skip the expensive clone.
228 let p2pReachable = false
230229 try {
231 fs.mkdirSync(path.dirname(installDir), { recursive: true })
232 await execGitInDir(path.dirname(installDir), [
233 'clone', '--depth', '1', '-b', 'release', cloneUrl, name
234 ])
235 return finishInstall(repoName, name, installDir, flags, 'git')
230 log('Checking P2P connectivity to ' + cloneUrl + '...')
231 await execGitInDir(os.tmpdir(), ['ls-remote', '--exit-code', cloneUrl, 'refs/heads/release'], { timeout: 20000 })
232 p2pReachable = true
233 log('P2P connection OK')
236234 } catch (err) {
237 log('P2P git clone failed (' + err.message + '), falling back to HTTP archive...')
238 cleanup(installDir)
235 log('P2P unreachable (' + err.message.split('\n')[0] + '), skipping clone')
236 }
237
238 if (p2pReachable) {
239 if (flags.force) cleanup(installDir)
240
241 log('Cloning ' + repoName + ' (release branch) from ' + cloneUrl + '...')
242
243 try {
244 fs.mkdirSync(path.dirname(installDir), { recursive: true })
245 await execGitInDir(path.dirname(installDir), [
246 'clone', '--depth', '1', '-b', 'release', cloneUrl, name
247 ])
248 return finishInstall(repoName, name, installDir, flags, 'git')
249 } catch (err) {
250 log('P2P git clone failed (' + err.message + '), falling back to HTTP archive...')
251 cleanup(installDir)
252 }
239253 }
240254 }
241255