OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-sync commits / ccfe2bf

0.1.4: never cache a null _ensureRemoteHelper result (retry until resolvable)
The 0.1.3 resolver fix is correct (proven: a fresh instance writes a shim to the complete hoisted helper), but the daemon stayed helper-less: _ensureRemoteHelper's FIRST call fires very early in boot, can return null before module resolution is ready, and the old `!== undefined` cache guard pinned that null forever → every subsequent pull got no helper on PATH → org joiners still got refs but zero objects. Fix: cache ONLY a truthy dir; a null/failed result is not cached, so the next pull retries and succeeds once the tree is settled. Verified locally (success cached, retry semantics sound). See pear-git #3. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ccfe2bf1e87ccd1cf0a96fa037d95000d9029a65
by plankatron <fleeky@gmail.com> · 2026-07-18T20:42:46.000Z

Changed files (2) +9 -5

index.js +8 -4
……@@ -496,8 +496,12 @@ module.exports = class HyperSync extends ReadyResource {
496496 // falls back to whatever `git-remote-punch` is already on PATH — no regression
497497 // for hosts that already have it).
498498 _ensureRemoteHelper () {
499 if (this._remoteHelperDir !== undefined) return this._remoteHelperDir;
500 this._remoteHelperDir = null;
499 // Cache ONLY a successful dir. A null/failed result is NOT cached, so we
500 // RETRY on the next pull — the first call can fire very early in boot before
501 // module resolution is ready (returning null); caching that null (the old
502 // `!== undefined` guard) stuck the daemon helper-less forever → org joiners
503 // got refs but zero objects even with the resolution fix in place.
504 if (this._remoteHelperDir) return this._remoteHelperDir;
501505 try {
502506 // Resolve git-remote-punch's bin. ORDER MATTERS: prefer the MODULE-RESOLVED
503507 // (hoisted top-level) copy. In content-addressed pgh bundles, hyper-sync's
……@@ -546,10 +550,10 @@ module.exports = class HyperSync extends ReadyResource {
546550 fs.writeFileSync(shimPath, '#!/bin/sh\nexec "' + barePath + '" "' + helperBin + '" "$@"\n');
547551 fs.chmodSync(shimPath, 0o755);
548552 this._remoteHelperDir = dir;
553 return dir;
549554 } catch {
550 this._remoteHelperDir = null;
555 return null; // not cached — retry next call
551556 }
552 return this._remoteHelperDir;
553557 }
554558
555559 // Env for a `git` child, with the self-provisioned git-remote-punch helper
package.json +1 -1
……@@ -1,6 +1,6 @@
11{
22 "name": "hyper-sync",
3 "version": "0.1.3",
3 "version": "0.1.4",
44 "description": "Manage and sync bare git repos over Hyperswarm",
55 "main": "index.js",
66 "imports": {