OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-sync commits / 0a0232b

Fix topic derivation: crypto.hash to match git-remote-punch
Server used crypto.data, client uses crypto.hash. Different domain- separation prefix → different topics → server announces on topic A, client joins topic B, never find each other on the per-repo swarm. Clients silently fall onto the daemon's identity-level topic via pre-existing connections, receive non-git bytes from the daemon's other handlers, and crash with 'bad line length character' + double- free during cleanup. Symptom: pgh app resync reports gitAdded but the bare repos stay empty. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0a0232bf99110fc4d3d956879fbbcb04455fe7b9
by plankatron <noreply@anthropic.com> · 2026-04-21T02:08:09.000Z

Changed files (1) +7 -1

lib/topics.js +7 -1
……@@ -9,7 +9,13 @@ function deriveTopic (serverKey, repoName) {
99 const keyBuf = typeof serverKey === 'string'
1010 ? Buffer.from(serverKey, 'hex')
1111 : serverKey;
12 return crypto.data(Buffer.concat([keyBuf, Buffer.from(repoName)]));
12 // MUST match git-remote-punch's deriveTopicFromKey (crypto.hash, not
13 // crypto.data — different domain-separation prefix). Using crypto.data
14 // here produces a topic the client never joins; clients silently land
15 // on the daemon's identity topic via existing pre-established
16 // connection, receive non-git bytes, and error with "bad line length
17 // character" + double-free during cleanup. Discovered 2026-04-20.
18 return crypto.hash(Buffer.concat([keyBuf, Buffer.from(repoName, 'utf-8')])).subarray(0, 32);
1319}
1420
1521module.exports = { deriveTopic };