Skip to content

Commit 931db77

Browse files
committed
refactor: move upload initialization into the writing event pipeline to ensure streams are correctly piped before upload start
1 parent ee5221c commit 931db77

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎handwritten/storage/src/file.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,16 +2309,7 @@ class File extends ServiceObject<File, FileMetadata> {
23092309
fileWriteStreamMetadataReceived = true;
23102310
});
23112311

2312-
writeStream.once('writing', async () => {
2313-
if (options.resumable === false) {
2314-
await this.startSimpleUpload_(
2315-
fileWriteStream,
2316-
options as CreateWriteStreamOptionsInternal,
2317-
);
2318-
} else {
2319-
await this.startResumableUpload_(fileWriteStream, options);
2320-
}
2321-
2312+
writeStream.once('writing', () => {
23222313
pipeline(
23232314
emitStream,
23242315
...(transformStreams as [Transform]),
@@ -2375,6 +2366,15 @@ class File extends ServiceObject<File, FileMetadata> {
23752366
}
23762367
},
23772368
);
2369+
2370+
if (options.resumable === false) {
2371+
this.startSimpleUpload_(
2372+
fileWriteStream,
2373+
options as CreateWriteStreamOptionsInternal,
2374+
);
2375+
} else {
2376+
this.startResumableUpload_(fileWriteStream, options);
2377+
}
23782378
});
23792379

23802380
return writeStream;

0 commit comments

Comments
 (0)