Skip to content

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

fix: green the Windows CI suite (CRLF split + fixed-sleep peer-sync waits) (#4096)

[._.]/ Adam Eivyc99062546266
diff --git a/.changelog/next/fixed-issue-4088.md b/.changelog/next/fixed-issue-4088.md
new file mode 100644
index 0000000000..daee9aa8bd
--- /dev/null
+++ b/.changelog/next/fixed-issue-4088.md
@@ -0,0 +1 @@
+- Windows CI: the HuggingFace download helper test now splits Python output on CRLF, and the peer-sync subscribe tests wait on the real drain instead of a 10ms sleep.
diff --git a/scripts/hf_download_repo.test.js b/scripts/hf_download_repo.test.js
index f607380106..ad10b73947 100644
--- a/scripts/hf_download_repo.test.js
+++ b/scripts/hf_download_repo.test.js
@@ -54,7 +54,10 @@ print(helper.incomplete_bytes("/tmp/portos-hf-cache-does-not-exist"))
print(helper.format_bytes_stage(1, 1, 26843545600, 51506295440, "qwen3vl.safetensors"))
print(helper.format_verify_stage(1, 1, "qwen3vl.safetensors"))
`);
- const [bytes, verify] = output.trim().split('\n');
+ // Python's print() emits CRLF on Windows, and `.trim()` only strips the ends
+ // of the whole payload — a bare split('\n') leaves a trailing \r on every
+ // line but the last, so the first assertion compared against 'STAGE:…\r'.
+ const [bytes, verify] = output.trim().split(/\r?\n/);
expect(bytes).toBe('STAGE:bytes:1/1:26843545600/51506295440:qwen3vl.safetensors');
expect(verify).toBe('STAGE:verify:1/1:qwen3vl.safetensors');
});
diff --git a/server/services/sharing/peerSync.test.js b/server/services/sharing/peerSync.test.js
index 4501a9c3c8..9e54fb64a6 100644
--- a/server/services/sharing/peerSync.test.js
+++ b/server/services/sharing/peerSync.test.js
@@ -460,13 +460,17 @@ describe('peerSync', () => {
vi.mocked(getUniverse).mockResolvedValue({ id: 'u1', name: 'Foo' });
vi.mocked(peerFetch).mockResolvedValue({ ok: true, json: async () => ({ missingAssets: [] }) });
await subscribePeer({ peerId: 'peer-a', recordKind: 'universe', recordId: 'u1' });
- await new Promise((r) => setTimeout(r, 10));
+ // subscribePeer registers the fire-and-forget initial push BEFORE it
+ // resolves, so the drain is a deterministic barrier for it. A fixed 10ms
+ // sleep was not: on a contended Windows CI runner the push chain had not
+ // reached peerFetch yet and this asserted 0 > 0.
+ await __drainForTests();
// First subscribe DID push.
expect(vi.mocked(peerFetch).mock.calls.length).toBeGreaterThan(0);
vi.mocked(peerFetch).mockClear();
// Second subscribe is idempotent — no push should fire.
const second = await subscribePeer({ peerId: 'peer-a', recordKind: 'universe', recordId: 'u1' });
- await new Promise((r) => setTimeout(r, 10));
+ await __drainForTests();
expect(second.created).toBe(false);
expect(vi.mocked(peerFetch)).not.toHaveBeenCalled();
});
@@ -495,9 +499,11 @@ describe('peerSync', () => {
{ peerId: 'peer-a', recordKind: 'universe', recordId: 'u1' },
{ adoptedFromReverse: true },
);
- // peerFetch may have been called for some other reason, but NOT
- // synchronously from this code path. Allow a small wait to be sure.
- await new Promise((r) => setTimeout(r, 10));
+ // peerFetch may have been called for some other reason, but NOT from
+ // this code path. Drain rather than sleep: a negative assertion has to
+ // outlast any push that WOULD have been scheduled, and the drain does
+ // that deterministically instead of betting on a 10ms budget.
+ await __drainForTests();
expect(peerFetch).not.toHaveBeenCalled();
});
});
@@ -1199,9 +1205,11 @@ describe('peerSync', () => {
// Create a sub with the initial push FAILING — leaves lastPushedAt=null.
vi.mocked(peerFetch).mockResolvedValueOnce(null);
await subscribePeer({ peerId: 'peer-a', recordKind: 'universe', recordId: 'u1' });
- // Wait for the fire-and-forget initial push to settle so the
- // persisted lastPushedAt is final before we re-check it.
- await new Promise((r) => setTimeout(r, 10));
+ // Wait for the fire-and-forget initial push to settle so the persisted
+ // lastPushedAt is final before we re-check it. Deterministic drain, not a
+ // fixed sleep — the assertion below is a negative (lastPushedAt stayed
+ // null), which vi.waitFor cannot poll for.
+ await __drainForTests();
const stale = await findPeerSubscription('peer-a', 'universe', 'u1');
expect(stale.lastPushedAt).toBeNull();
// Peer comes back — retry must succeed and stamp lastPushedAt.