Migrate LoRA downloads onto the shared download slot - #6221
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
downloadToFileinserver/services/loras.jsnow claims acreateDownloadSlotslot (keyed on the resolved destination path) before its first await, matching the pattern already used byspecDecodeModels.jsandslotstreamModelManager.js.orphanedPartialGc.js) can now see a live LoRA download's.partialviaisAnyDownloadInFlight— previously it was the one download path the sweep could reach but not protect.LORA_DOWNLOAD_IN_FLIGHTinstead of racing a parallel transfer of the same file.LORA_DOWNLOAD_CANCELLED/LORA_DOWNLOAD_STALLEDerror as any other cancel/stall.downloadPreflight.jsandorphanedPartialGc.jsthat 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.npx vitest rununderserver/) passes: 1935 files, 39064 tests.opencodeplan-agent review of the branch diff: no blocking issues.