File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -4141,8 +4141,7 @@ class File extends ServiceObject<File, FileMetadata> {
41414141 ) {
41424142 retryOptions . autoRetry = false ;
41434143 }
4144-
4145- const uploadStream = resumableUpload . upload ( {
4144+ const cfg = {
41464145 authClient : this . storage . authClient ,
41474146 apiEndpoint : this . storage . apiEndpoint ,
41484147 bucket : this . bucket . name ,
@@ -4168,7 +4167,17 @@ class File extends ServiceObject<File, FileMetadata> {
41684167 highWaterMark : options ?. highWaterMark ,
41694168 universeDomain : this . bucket . storage . universeDomain ,
41704169 [ GCCL_GCS_CMD_KEY ] : options [ GCCL_GCS_CMD_KEY ] ,
4171- } ) ;
4170+ } ;
4171+
4172+ let uploadStream : resumableUpload . Upload ;
4173+
4174+ try {
4175+ uploadStream = resumableUpload . upload ( cfg ) ;
4176+ } catch ( error ) {
4177+ dup . destroy ( error as Error ) ;
4178+ this . storage . retryOptions . autoRetry = this . instanceRetryValue ;
4179+ return ;
4180+ }
41724181
41734182 uploadStream
41744183 . on ( 'response' , resp => {
Original file line number Diff line number Diff line change @@ -1991,6 +1991,25 @@ describe('File', () => {
19911991 writable . write ( 'data' ) ;
19921992 } ) ;
19931993
1994+ it ( 'should emit RangeError' , done => {
1995+ const error = new RangeError (
1996+ 'Cannot provide an `offset` without providing a `uri`'
1997+ ) ;
1998+
1999+ const opitons = {
2000+ offset : 1 ,
2001+ isPartialUpload : true ,
2002+ } ;
2003+ const writable = file . createWriteStream ( opitons ) ;
2004+
2005+ writable . on ( 'error' , ( err : RangeError ) => {
2006+ assert . deepEqual ( err , error ) ;
2007+ done ( ) ;
2008+ } ) ;
2009+
2010+ writable . write ( 'data' ) ;
2011+ } ) ;
2012+
19942013 it ( 'should emit progress via resumable upload' , done => {
19952014 const progress = { } ;
19962015
You can’t perform that action at this time.
0 commit comments