Skip to content

fix(hosts): keep the upload-retention retry timer ref'd so it fires on Windows (fixes #536) - #550

Merged
kahme247 merged 2 commits into
mainfrom
fix-issue-536-2026-11-23
Nov 23, 2026
Merged

kahme247 merged 2 commits into
mainfrom
fix-issue-536-2026-11-23

Conversation

@kahme247

@kahme247 kahme247 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #536: on Windows CI the upload-retention retry could be lost — "the
current policy to retry" never arrived at the daemon, leaving it on a
superseded policy until the next hello or change.

lib/hosts/upload-retention-sync.ts armed the retry with an unref'd
setTimeout. An unref'd timer may never fire when nothing else keeps the
event loop alive, which is what was observed on Windows CI. The retry is now
deliberately ref'd: it must fire even when nothing else keeps the loop alive.
The callback re-checks the link and the current setting before sending, so a
late fire is harmless, and it never re-arms after disconnect.

Caveat: the root cause is still unproven on Windows — the unref'd timer is
the mechanism that fits the observed symptom, but this needs a Windows CI
run to confirm the flake is gone.

Tests (fresh main c110474, bun test): the existing
lib/hosts/upload-retention-sync.test.mjs suite (6 tests, including the
retry-behaviour tests) passes; the targeted set for all three issues
(11 tests across 4 files) passes. tsc --noEmit clean.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of upload-retention updates by keeping eligible retries scheduled. Retries stop if the host disconnects or the retention setting changes.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Upload-retention retry timers remain referenced until they fire. Retry guards, capped exponential backoff, and disconnect behavior are unchanged.

Changes: Upload-retention retry

Layer / File(s) Summary
Keep retry timer referenced
lib/hosts/upload-retention-sync.ts
The retry timer is no longer unreferenced. The existing retry checks and capped exponential backoff remain unchanged.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Suggested reviewers: andrebrait

Merge Risk: Minimal · up to 05eec

Merge Risk: ⚪ Minimal · up to 05eec

Upload-retention retries now fire reliably even when nothing else keeps the process alive. The retry checks and backoff are unchanged, and shutdown still exits explicitly. No merge-blocking risk remains; a Windows CI run will confirm the flake is gone.

Architecture risk: Low · up to 4a014

The change affects 1 system.

Changed systems: lib

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — lib (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in lib/hosts/upload-retention-sync.ts: Retry timers are no longer unreferenced, so they keep the event loop alive until firing. The retry’s link and current-setting checks, exponential backoff, and 30-second cap remain unchanged.
  • observed — Modified behavior in lib/hosts/upload-retention-sync.ts: The timer.unref() call was removed.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the actual change: the upload-retention retry timer is kept ref'd (not unref'd), and the stated purpose is to make it fire on Windows. The raw summary confirms the change replaces unre…
Linked Issues check Passed Issue #536 asks for a fix to the open lead: the unref'd setTimeout in lib/hosts/upload-retention-sync.ts can lose the upload-retention retry. The reviewed diff (merge base 743af31 to head 4a014d6) r…
Out of Scope Changes check Passed The whole-PR diff changes only lib/hosts/upload-retention-sync.ts (+7/-2). The change removes timer.unref() and adds a comment that explains why the retry is ref'd. Every changed line is part of the r…
Full details: Title check

Explanation

The title names the actual change: the upload-retention retry timer is kept ref'd (not unref'd), and the stated purpose is to make it fire on Windows. The raw summary confirms the change replaces unref() with a referenced timer in lib/hosts/upload-retention-sync.ts, and the linked issue #536 describes the unref'd setTimeout as the suspected lead. The title is specific, but the objectives say the root cause is unproven, so 'so it fires on Windows' states an intent that CI has not yet confirmed.

Full details: Linked Issues check

Explanation

Issue #536 asks for a fix to the open lead: the unref'd setTimeout in lib/hosts/upload-retention-sync.ts can lose the upload-retention retry. The reviewed diff (merge base 743af31 to head 4a014d6) removes timer.unref() from the retry in send(). The retry now stays referenced, so it fires even when nothing else keeps the event loop alive. The callback still checks getHost, isLinkUp, and loadWebServerSettings().uploadRetentionDays === days before it re-sends, so a superseded policy is not restored. No code path re-arms the timer after disconnect. The change targets the lead named in #536. Scope limits: the root cause is not proven, and no Windows run was done in this review. The issue lists a Windows reproduction as a next step, which is not a coding requirement. No new automated test was added in this diff. The PR description reports that the existing test file passes.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff changes only lib/hosts/upload-retention-sync.ts (+7/-2). The change removes timer.unref() and adds a comment that explains why the retry is ref'd. Every changed line is part of the retry path that #536 names. No unrelated code, configuration, or tests are changed in the reviewed diff.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb3ec0ba-cc35-4415-8750-f39c159efd19
Commits

Reviewing files that changed from the base of the PR and between 5d7232a and 4a014d6.

Files selected for processing: 1

  • lib/hosts/upload-retention-sync.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@kahme247
kahme247 merged commit 1c191dc into main Nov 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows CI: upload-retention retry after a superseded policy never arrived (flake, root cause unknown)

1 participant