Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: assetHash test comment + peer-sync uninstaller
Adam Eivy0a01959b7a08
diff --git a/server/lib/assetHash.test.js b/server/lib/assetHash.test.jsindex 3bcaf8c2df..98c244d656 100644--- a/server/lib/assetHash.test.js+++ b/server/lib/assetHash.test.js@@ -4,9 +4,13 @@ import { join, dirname } from 'path';import { tmpdir } from 'os';import { sidecarPathForImage, getOrComputeImageSha256 } from './assetHash.js';-// PATHS.images is resolved at module-load from fileUtils. We monkey-patch it-// per-test by writing a tmpdir-rooted image and pointing the sidecar resolver-// at it via the same getOrComputeImageSha256 signature.+// PATHS.images is resolved at module-load from fileUtils and we deliberately+// do NOT monkey-patch it — the absent-file tests use a tmpdir-rooted dir for+// negative cases, but the positive sha256-compute / cache / invalidate tests+// write fixtures into the REAL PATHS.images dir under a unique+// `portos-assethash-test-*` token so the sidecar resolver hits a real+// callsite. Each test wraps in try/finally to clean up the fixture even on+// assertion failure (see the body of each `it()` below).let imageDir;diff --git a/server/services/sharing/index.js b/server/services/sharing/index.jsindex 37245a5779..a1903f38d1 100644--- a/server/services/sharing/index.js+++ b/server/services/sharing/index.js@@ -12,7 +12,7 @@ import { join } from 'path';import { attachAllWatchers, attachWatcher, detachWatcher, shutdownAllWatchers, listAttachedWatchers } from './watcher.js';import { sharingEvents } from './importer.js';import { installSubscriptionListener } from './subscriptions.js';-import { installPeerSyncListener, peerSyncEvents } from './peerSync.js';+import { installPeerSyncListener, uninstallPeerSyncListener, peerSyncEvents } from './peerSync.js';import { initAnnotationsSync } from './annotationsSync.js';export { sharingEvents } from './importer.js';@@ -80,6 +80,11 @@ export async function initSharing({ io: socketIo } = {}) {export async function shutdownSharing() {await shutdownAllWatchers();sharingEvents.removeAllListeners();+ // Detach the recordEvents + instanceEvents listeners that+ // installPeerSyncListener attached. Without this, the peer-sync service+ // listeners stay attached after shutdown and pollute any subsequent+ // re-init or test teardown.+ uninstallPeerSyncListener();peerSyncEvents.removeAllListeners();initialized = false;io = null;diff --git a/server/services/sharing/peerSync.js b/server/services/sharing/peerSync.jsindex 6924c8a687..d154abf22a 100644--- a/server/services/sharing/peerSync.js+++ b/server/services/sharing/peerSync.js@@ -1482,11 +1482,13 @@ export function installPeerSyncListener() {}/**- * Test-only: clear pending debounces, detach our listener, and await any- * in-flight state writes so the test can rm-rf the tmpdir without an- * ENOTEMPTY race. Async so callers can `await __resetForTests()`.+ * Detach the recordEvents + instanceEvents listeners and clear pending+ * debounces. Mirror image of `installPeerSyncListener`. Called from+ * `shutdownSharing` so the peer-sync service has a clean stop/start+ * lifecycle (otherwise listeners leak across server re-inits and pollute+ * test teardown when a follow-up test re-creates events).*/-export async function __resetForTests() {+export function uninstallPeerSyncListener() {for (const t of pendingTimers.values()) clearTimeout(t);pendingTimers.clear();if (onUpdated) recordEvents.off('updated', onUpdated);@@ -1495,5 +1497,14 @@ export async function __resetForTests() {onUpdated = null;onDeleted = null;onPeerOnline = null;+}++/**+ * Test-only: full reset including a `writeTail` await so the test can+ * rm-rf its tmpdir without an ENOTEMPTY race. Wraps uninstallPeerSyncListener+ * so the listener-detach logic stays single-sourced.+ */+export async function __resetForTests() {+ uninstallPeerSyncListener();await writeTail.catch(() => {});}