[setup-r] retry transient r-hub.io request failures#1088
Open
nbenn wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v2-branch #1088 +/- ##
==========================================
Coverage 83.33% 83.33%
==========================================
Files 3 3
Lines 12 12
==========================================
Hits 10 10
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0400ce9 to
df1765e
Compare
a33df6d to
3163b59
Compare
determineVersion() resolves the R version with a single GET to api.r-hub.io through getJSON(), with no retry, so a transient timeout or server error fails the whole job (e.g. "Request timeout: /rversions/resolve/release/linux-ubuntu-24.04/x86_64"). Wrap the fetch in getJSON() in a retry loop: 4 attempts, exponential backoff (1s / 5s / 25s), and a per-attempt 15s timeout via AbortSignal.timeout(). Only transient failures are retried: thrown network/timeout errors and 5xx/429/408 responses. getReleaseVersion(), the other r-hub caller, gets the same resilience. A 404 (or any other stable response) still returns undefined immediately, and once the retries are exhausted getJSON() returns undefined the same way -- it never throws -- so the callers' existing behaviour is preserved: determineVersion() still does its arm64 -> intel macOS fallback and raises "Failed to resolve R version ...", and getReleaseVersion() still degrades to an empty version string. Each failure -- a non-retryable status or an exhausted retry -- is logged with core.debug, matching the rest of the file. dist/index.js rebuilt with ncc.
3163b59 to
e318527
Compare
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.
determineVersion()resolves the R version with a singleGETtoapi.r-hub.iothroughgetJSON(), with no retry, so a transient timeout or server error fails the whole job — e.g.Error: Request timeout: /rversions/resolve/release/linux-ubuntu-24.04/x86_64.This wraps the
fetchingetJSON()in a small retry loop: 4 attempts, exponential backoff (1s / 5s / 25s), and a per-attempt 15s timeout viaAbortSignal.timeout()so a stalled connection aborts and the next attempt can proceed.Only transient failures are retried — thrown network/timeout errors and
5xx/429/408responses. A404, or any other stable response, still returnsundefinedimmediately, and once the retries are exhaustedgetJSON()returnsundefinedthe same way — it never throws. So both callers' existing behaviour is preserved:determineVersion()still does its arm64 → intel macOS fallback and raisesFailed to resolve R version …, andgetReleaseVersion()still degrades to an empty version string. Both failure paths — a non-retryable status, and exhausted retries — are logged withcore.debug, matching the rest of the file. I put the retry ingetJSON()rather than at the one resolve call site so thatgetReleaseVersion()— the other r-hub caller — gets the same resilience; happy to narrow it to just the resolveGETif you'd prefer.I verified the control flow locally against a stubbed
fetch: immediate success → one call, no retry; transient error /5xx/429→ retries then recovers;404→ no retry, returnsundefined; persistent failure → returnsundefinedafter 4 attempts so the caller falls back as before. Thesetup-raction has no unit-test harness, so I didn't add a test here — glad to wire one up if that would be welcome.dist/index.jsrebuilt withncc.Fixes #1086