fix: fix race condition in embed and diffusion download utilities#1052
Closed
gianni-cor wants to merge 1 commit into
Closed
fix: fix race condition in embed and diffusion download utilities#1052gianni-cor wants to merge 1 commit into
gianni-cor wants to merge 1 commit into
Conversation
Port the proven download pattern from the LLM package (PR #1019): - Wait for fs.unlink callback before recursing on redirect - Add safeResolve/safeReject guards to prevent double settlement - Handle 307/308 redirects in embed examples/utils.js - Add fileStream and response error handlers - Use URL constructor for safer redirect resolution - Use close event instead of finish for write completion Made-with: Cursor
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.
What problem does this PR solve?
The embed and diffusion packages have the same download utility race conditions that were fixed in the LLM package by PR #1019:
qvac-lib-infer-llamacpp-embed/examples/utils.js: Had all the original bugs — fire-and-forgetfs.unlink, only handled 301/302, no double-settlement guards, no fileStream/response error handlersqvac-lib-infer-llamacpp-embed/test/integration/utils.js: Fire-and-forgetfs.unlink, nosafeResolve/safeRejectguards, no error handlers, usedfinishinstead ofcloselib-infer-diffusion/test/integration/utils.js: ManualstartsWith('/')redirect handling instead ofnew URL()constructorHow does it solve it?
Port the proven download pattern from the LLM package (PR #1019):
fs.unlinkcallback before recursing on redirectsafeResolve/safeRejectguards to prevent double settlementexamples/utils.jsfileStream.on('error')andresponse.on('error')handlersnew URL(location, base).hreffor safer redirect resolutioncloseevent instead offinishfor write completionHow was it tested?
Code review — the changes are identical to the pattern already battle-tested in
qvac-lib-infer-llamacpp-llm/test/integration/utils.jsand validated end-to-end in PR #1019.Made with Cursor