Skip to content

Commit 5c783a9

Browse files
Copiloticlanton
andauthored
address code review feedback: improve type annotations and JSDoc
Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/050e10a7-3cad-4da4-93e5-9941453283b9 Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
1 parent 2462253 commit 5c783a9

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

libraries/rush-lib/src/logic/buildCache/ICloudBuildCacheProvider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export interface ICloudBuildCacheProvider {
2424
* If implemented, the build cache will prefer to use this method over
2525
* {@link ICloudBuildCacheProvider.trySetCacheEntryBufferAsync} to avoid loading the entire
2626
* cache entry into memory.
27+
*
28+
* @remarks
29+
* Because the provided stream can only be consumed once, implementations should not
30+
* attempt to retry the upload using the same stream. If retry logic is needed,
31+
* consider buffering internally or returning `false` so the caller can retry.
2732
*/
2833
trySetCacheEntryStreamAsync?(
2934
terminal: ITerminal,

libraries/rush-lib/src/logic/buildCache/OperationBuildCache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as path from 'node:path';
55
import * as crypto from 'node:crypto';
6-
import { createReadStream } from 'node:fs';
6+
import { type ReadStream, createReadStream } from 'node:fs';
77
import type { Readable } from 'node:stream';
88

99
import { FileSystem, type FolderItem, InternalError, Async } from '@rushstack/node-core-library';
@@ -333,7 +333,7 @@ export class OperationBuildCache {
333333

334334
if (this._cloudBuildCacheProvider.trySetCacheEntryStreamAsync) {
335335
// Use streaming upload to avoid loading the entire cache entry into memory
336-
const entryStream: import('node:fs').ReadStream = createReadStream(localCacheEntryPath);
336+
const entryStream: ReadStream = createReadStream(localCacheEntryPath);
337337
setCloudCacheEntryPromise = this._cloudBuildCacheProvider.trySetCacheEntryStreamAsync(
338338
terminal,
339339
cacheId,

libraries/rush-lib/src/utilities/WebClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ function _sendRequestBody(
299299
body: Buffer | Readable | undefined,
300300
reject: (error: Error) => void
301301
): void {
302-
if (body && typeof (body as Readable).pipe === 'function') {
302+
const isStream: boolean = !!body && typeof (body as Readable).pipe === 'function';
303+
if (isStream) {
303304
(body as Readable).on('error', reject);
304305
(body as Readable).pipe(req);
305306
} else {

0 commit comments

Comments
 (0)