[Node.js] Follow HTTP 3xx redirects in onnxruntime-node install scripts#28618
Open
adityasingh2400 wants to merge 1 commit into
Open
Conversation
js/node/script/install-utils.js previously treated any non-200 response as a fatal error, including 301/302/303/307/308 redirects. When the NuGet release host returns a 302 to the actual artifact (recent behavior), 'npm install onnxruntime-node' fails outright. Resolve the Location header against the current URL and recurse, capped at five redirects to avoid loops. Fixes microsoft#28265 Fixes microsoft#28393
Author
|
@microsoft-github-policy-service agree |
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.
Description
js/node/script/install-utils.jspreviously treated any non-200 response as a fatal error, so an HTTP 301/302/303/307/308 redirect on a metadata or artifact URL abortednpm install onnxruntime-nodewith messages like:The NuGet Server API documents that requests may return 301/302 and clients are expected to follow the
Locationheader. This is currently being observed in the wild againsthttps://api.nuget.org/v3/index.json, which 302s to a regional mirror.Fix
Both
downloadFile()anddownloadJson()now:Locationheader,new URL(res.headers.location, currentUrl)(handles both absolute and relativeLocationvalues),doRequest(currentUrl, redirectsLeft)helper,Existing 200 / 4xx / non-redirect-non-200 paths are unchanged, so no other behavior regresses.
Motivation and Context
Fixes #28265
Fixes #28393
Both reporters independently observed the same root cause (Linux/WSL2 hitting a 302 from the NuGet index endpoint) and proposed essentially the same fix. This PR implements it.