Skip to content

Commit 84a44b7

Browse files
Copiloticlanton
andauthored
Address code review: add documentation for type assertion and no-retry streaming upload
Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/6212baeb-266c-4823-94df-251c69a8f74c Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
1 parent 733ef5c commit 84a44b7

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

common/reviews/api/rush-amazon-s3-build-cache-plugin.api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export class AmazonS3Client {
2828
static tryDeserializeCredentials(credentialString: string | undefined): IAmazonS3Credentials | undefined;
2929
// (undocumented)
3030
uploadObjectAsync(objectName: string, objectBuffer: Buffer): Promise<void>;
31-
// (undocumented)
3231
uploadObjectStreamAsync(objectName: string, objectStream: Readable): Promise<void>;
3332
// (undocumented)
3433
static UriEncode(input: string): string;

rush-plugins/rush-amazon-s3-build-cache-plugin/src/AmazonS3Client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ export class AmazonS3Client {
234234
});
235235
}
236236

237+
/**
238+
* Uploads a readable stream to S3. Unlike {@link AmazonS3Client.uploadObjectAsync}, this method
239+
* does not use retry logic because the stream is consumed after the first attempt and cannot be
240+
* replayed. The caller should handle failures accordingly.
241+
*/
237242
public async uploadObjectStreamAsync(objectName: string, objectStream: Readable): Promise<void> {
238243
if (!this._credentials) {
239244
throw new Error('Credentials are required to upload objects to S3.');

rush-plugins/rush-azure-storage-build-cache-plugin/src/AzureStorageBuildCacheProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ export class AzureStorageBuildCacheProvider
206206
const readableStreamBody: NodeJS.ReadableStream | undefined =
207207
downloadResponse.readableStreamBody;
208208
if (readableStreamBody) {
209+
// The Azure SDK types readableStreamBody as NodeJS.ReadableStream, which is a minimal
210+
// interface. In practice, the underlying implementation is a Node.js Readable stream
211+
// (http.IncomingMessage), so this assertion is safe.
209212
return readableStreamBody as unknown as Readable;
210213
}
211214
return undefined;

0 commit comments

Comments
 (0)