Skip to content
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

actions: promote release action #142

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Conversation

flakey5
Copy link
Member

@flakey5 flakey5 commented Oct 5, 2024

Signed-off-by: flakey5 <[email protected]>
@flakey5 flakey5 force-pushed the flakey5/20241004/promote-action branch from 8e7f6cd to 5d94b1c Compare October 5, 2024 04:04
scripts/promote-release.js Outdated Show resolved Hide resolved
scripts/promote-release.js Outdated Show resolved Hide resolved
scripts/promote-release.js Outdated Show resolved Hide resolved
scripts/promote-release.js Outdated Show resolved Hide resolved
let r2Error;

for (let i = 0; i < RETRY_LIMIT; i++) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Promise alike then.catch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like

for (let i = 0; i < R2_RETRY_COUNT; i++) {
  result
    .then(/*...*/)
    .catch(/*...*/)
}

?

If so it would send the same request multiple times regardless if it succeeded or not since there's nothing blocking the execution context (like await is doing here)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you want to await on it. You can still do:

const somethingThatReturnsPromise = invokeSomething.catch();

await somethingThatReturnsPromise;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting this is just a copy of this function here

export async function retryWrapper<T>(
request: () => Promise<T>,
retryLimit: number,
sentry?: Toucan
): Promise<T> {
let r2Error: unknown = undefined;
for (let i = 0; i < retryLimit; i++) {
try {
const result = await request();
return result;
} catch (err) {
r2Error = err;
}
}
if (sentry !== undefined) {
sentry.captureException(r2Error);
}
throw r2Error;
}

Why .catch() over the try/catch?

scripts/promote-release.js Outdated Show resolved Hide resolved
Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few nits; I also added screenshots of it running and working on a dry run.

Signed-off-by: flakey5 <[email protected]>
Signed-off-by: flakey5 <[email protected]>

Signed-off-by: flakey5 <[email protected]>
@flakey5 flakey5 force-pushed the flakey5/20241004/promote-action branch from 75a68db to fcd95a9 Compare October 15, 2024 06:20

for (let i = 0; i < R2_RETRY_COUNT; i++) {
try {
const result = await request();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general await with a return is not needed? As an await on parent function call is also needed and enough.

const result = await request();
return result;
} catch (err) {
r2Error = err;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the throw happen here already?

const recursive =
process.argv.length === 4 && process.argv[3] === '--recursive';

if (recursive) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of if else, when not recursive make an array of one file :)

@flakey5 flakey5 merged commit 95e02b5 into main Oct 16, 2024
5 checks passed
@flakey5 flakey5 deleted the flakey5/20241004/promote-action branch October 16, 2024 23:39
@flakey5
Copy link
Member Author

flakey5 commented Oct 16, 2024

Follow up pr will be made addressing comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants