Skip to content

Migrate LoRA downloads onto the shared download slot - #6221

Merged
atomantic merged 2 commits into
mainfrom
claim/issue-6190
Sep 4, 2026
Merged

Migrate LoRA downloads onto the shared download slot#6221
atomantic merged 2 commits into
mainfrom
claim/issue-6190

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

  • downloadToFile in server/services/loras.js now claims a createDownloadSlot slot (keyed on the resolved destination path) before its first await, matching the pattern already used by specDecodeModels.js and slotstreamModelManager.js.
  • The orphaned-partial GC sweep (orphanedPartialGc.js) can now see a live LoRA download's .partial via isAnyDownloadInFlight — previously it was the one download path the sweep could reach but not protect.
  • A second install of the same destination while one is already downloading now fails fast with LORA_DOWNLOAD_IN_FLIGHT instead of racing a parallel transfer of the same file.
  • An external abort signal (the streaming HF install route's client-disconnect handler) now cancels through the slot, so it gets the same typed LORA_DOWNLOAD_CANCELLED/LORA_DOWNLOAD_STALLED error as any other cancel/stall.
  • Removed the "still unprotected" notes in downloadPreflight.js and orphanedPartialGc.js that pointed at this issue.

Closes #6190

Test plan

  • cd server && npx vitest run services/loras.test.js services/orphanedPartialGc.test.js lib/downloadPreflight.test.js routes/loras.test.js — all pass, including two new tests (duplicate-install refusal, GC protects an aged live-download .partial) and a rewritten abort test that proves the external signal cancels through the slot.
  • Full server suite (npx vitest run under server/) passes: 1935 files, 39064 tests.
  • Local opencode plan-agent review of the branch diff: no blocking issues.

loras.js was the only streamResumableDownload caller not registered
with createDownloadSlot, so the orphaned-partial GC sweep couldn't see
a live LoRA download's .partial (harmless today only because the age
gate outlives any fresh transfer) and a second install of the same
destination could race a parallel copy of the same file. Claims a slot
keyed on the resolved destination path before the first await, wires
an external abort signal (the SSE stream's client-disconnect handler)
to cancel through the slot so it gets the same typed error as a stall,
and releases in a finally. Not exclusive and keepPartialOnCancel
defaults false, matching the spec-decode single-file precedent.
…d test

Strengthens the abort-through-slot test from the prior commit per opencode
review feedback — asserts LORA_DOWNLOAD_CANCELLED, not just a message match.
@atomantic
atomantic merged commit a6947a5 into main Sep 4, 2026
7 checks passed
@atomantic
atomantic deleted the claim/issue-6190 branch September 4, 2026 07:12
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.

Migrate the LoRA download onto the shared download slot so the orphaned-partial GC protects it

1 participant