-
Notifications
You must be signed in to change notification settings - Fork 457
fix(setup-js): wrap all sync fs calls in try/catch (eslint-monster remediation) #46102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
bcda03f
b26624d
33a9b12
cd8142f
0c7442f
459c640
6d7bd76
9ce503b
1a85a2c
53bc123
b5f6b53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,7 @@ | |
| if (!url) { | ||
| throw new Error("ACTIONS_RESULTS_URL is required for artifact upload"); | ||
| } | ||
| return new URL(url).origin; | ||
| } | ||
|
|
||
| async function twirpRequest(method, body) { | ||
|
|
@@ -78,7 +78,7 @@ | |
| if (!runtimeToken) { | ||
| throw new Error("ACTIONS_RUNTIME_TOKEN is required for artifact upload"); | ||
| } | ||
| const url = new URL(`/twirp/${TWIRP_ARTIFACT_SERVICE}/${method}`, getResultsServiceOrigin()).toString(); | ||
|
Check warning on line 81 in actions/setup/js/artifact_client.cjs
|
||
|
|
||
| let lastError; | ||
| for (let attempt = 1; attempt <= DEFAULT_RETRY_ATTEMPTS; attempt++) { | ||
|
|
@@ -160,14 +160,14 @@ | |
| } | ||
|
|
||
| function ensureZipAvailable() { | ||
| const result = spawnSync("zip", ["-v"], { stdio: "ignore" }); | ||
|
Check warning on line 163 in actions/setup/js/artifact_client.cjs
|
||
| if (result.status !== 0) { | ||
| throw new Error("zip command is required to upload artifacts (for example: apt-get install zip)"); | ||
| } | ||
| } | ||
|
|
||
| function ensureUnzipAvailable() { | ||
| const result = spawnSync("unzip", ["-v"], { stdio: "ignore" }); | ||
|
Check warning on line 170 in actions/setup/js/artifact_client.cjs
|
||
| if (result.status !== 0) { | ||
| throw new Error("unzip command is required to download artifacts (for example: apt-get install unzip)"); | ||
| } | ||
|
|
@@ -282,7 +282,11 @@ | |
| } | ||
|
|
||
| const destination = options.path || process.env.GITHUB_WORKSPACE || process.cwd(); | ||
| fs.mkdirSync(destination, { recursive: true }); | ||
| try { | ||
| fs.mkdirSync(destination, { recursive: true }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good defensive handling — wrapping mkdirSync in try/catch gives a clearer failure message. Consider reusing a shared helper for this pattern across the codebase. |
||
| } catch (err) { | ||
| throw new Error(`Failed to create directory ${destination}: ${String(err)}`, { cause: err }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice use of the error cause option to preserve the original stack. The String(err) coercion is fine here for the message text. |
||
| } | ||
|
|
||
| const apiUrl = new URL(`/repos/${findBy.repositoryOwner}/${findBy.repositoryName}/actions/artifacts/${artifactId}/zip`, process.env.GITHUB_API_URL || "https://api.github.com"); | ||
| const redirectResponse = await fetch(apiUrl.toString(), { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.