Skip to content

Conversation

clee2000
Copy link
Contributor

@clee2000 clee2000 commented Sep 2, 2025

yarn test is broken on main, you can see this in

Testing:
Stole some environment variables from the lambda and mangled the key to upload to a dummy key then ran yarn build; cd dist;node -e 'require("./index").handler();' > t.log
Saw that it uploaded a file, and skipped some because they didn't need to be uploaded.
The one that was uploaded was arm64, which I'm thinking was uploaded manually since it lacks a tag on s3.

I had to add an await since it wasn't working, which I think is a bug in the original code

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 2, 2025
Copy link

vercel bot commented Sep 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Updated (UTC)
torchci Ignored Ignored Preview Sep 3, 2025 8:05pm

@clee2000 clee2000 force-pushed the csl/aws_sdk_runner_binaries branch from 1aae26f to 5f74300 Compare September 2, 2025 17:14
Tagging: versionKey + '=' + actionRunnerReleaseAsset.name,
Body: writeStream,
}).promise();
const upload = new Upload({
Copy link
Contributor Author

@clee2000 clee2000 Sep 2, 2025

Choose a reason for hiding this comment

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

The original upload function did multipart uploads automatically, but there is no upload function anymore, and putObject doesn't to multipart uploads. This doesn't matter if the file is small but idk how large the file is, so I use this to handle multipart uploads automatically. Code taken from chatgpt

@clee2000 clee2000 marked this pull request as ready for review September 2, 2025 20:16
@clee2000 clee2000 requested a review from a team September 2, 2025 20:16
"dependencies": {
"@aws-sdk/client-s3": "^3.879.0",
"@aws-sdk/lib-storage": "^3.879.0",
"@vercel/ncc": "^0.38.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

was getting build problems so I also swapped the ncc dependency. the other lambdas use @vercel, maybe not this version tho

Copy link
Member

Choose a reason for hiding this comment

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

This is more than likely correct

Copy link
Member

@seemethere seemethere left a comment

Choose a reason for hiding this comment

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

LGTM

"@jridgewell/gen-mapping" "^0.3.5"
"@jridgewell/trace-mapping" "^0.3.24"

"@aws-crypto/crc32@5.2.0":
Copy link
Member

Choose a reason for hiding this comment

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

nit: I wonder if we can add these to the linguist file at the root to note that these are generated files and should be automatically minimized in PR reviews.

This is unrelated to the migration work but just a thought I was having.

"dependencies": {
"@aws-sdk/client-s3": "^3.879.0",
"@aws-sdk/lib-storage": "^3.879.0",
"@vercel/ncc": "^0.38.3",
Copy link
Member

Choose a reason for hiding this comment

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

This is more than likely correct

Copy link
Contributor

@ZainRizvi ZainRizvi left a comment

Choose a reason for hiding this comment

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

Looks reasonable. Is this testable in canary?

@ZainRizvi ZainRizvi requested a review from Copilot September 3, 2025 19:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR upgrades the runner-binaries-syncer Lambda function from AWS SDK v2 to v3 to fix broken tests on the main branch. The changes modernize the S3 client usage and dependencies while maintaining the same functionality.

  • Replaces AWS SDK v2 imports and usage with v3 equivalents
  • Updates S3 client initialization and API calls to use the new SDK patterns
  • Migrates from @zeit/ncc to @vercel/ncc bundler

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/syncer/handler.ts Updates S3 client imports, initialization, and API calls to use AWS SDK v3 patterns
package.json Replaces AWS SDK v2 dependencies with v3 equivalents and updates bundler

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}).catch((error) => {
console.error(`Exception: ${error}`);
});
await uploadPromise;
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

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

The uploadPromise is awaited after the request stream has already finished, which could cause the upload to complete before all data is written. Move await uploadPromise; inside the Promise callback after writeStream.end() to ensure proper sequencing.

Copilot uses AI. Check for mistakes.

Comment on lines +21 to +22
const versions = objectTagging.TagSet?.filter((t: Tag) => t.Key === versionKey);
return versions?.length === 1 ? versions[0].Value : undefined;
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

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

The optional chaining versions?.length is inconsistent with the original logic. If versions is undefined, the condition should return undefined, but if it's an empty array, it should also return undefined. The original code versions.length === 1 would throw if versions is undefined, which may have been the intended behavior.

Suggested change
const versions = objectTagging.TagSet?.filter((t: Tag) => t.Key === versionKey);
return versions?.length === 1 ? versions[0].Value : undefined;
if (!objectTagging.TagSet) {
throw new Error('TagSet is undefined');
}
const versions = objectTagging.TagSet.filter((t: Tag) => t.Key === versionKey);
return versions.length === 1 ? versions[0].Value : undefined;

Copilot uses AI. Check for mistakes.

console.debug('latest: ' + currentVersion);
if (currentVersion === undefined || currentVersion != actionRunnerReleaseAsset.name) {
uploadToS3(s3, cacheObject, actionRunnerReleaseAsset);
await uploadToS3(s3, cacheObject, actionRunnerReleaseAsset);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add an await since uploadToS3 is an async function and is in a for loop, so this should wait for the upload to finish. Alt: add to a list of promises and await at the end

@clee2000 clee2000 merged commit 200cb0c into main Sep 5, 2025
5 checks passed
@clee2000 clee2000 deleted the csl/aws_sdk_runner_binaries branch September 5, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants