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> {
4141
4141
) {
4142
4142
retryOptions . autoRetry = false ;
4143
4143
}
4144
-
4145
- const uploadStream = resumableUpload . upload ( {
4144
+ const cfg = {
4146
4145
authClient : this . storage . authClient ,
4147
4146
apiEndpoint : this . storage . apiEndpoint ,
4148
4147
bucket : this . bucket . name ,
@@ -4168,7 +4167,17 @@ class File extends ServiceObject<File, FileMetadata> {
4168
4167
highWaterMark : options ?. highWaterMark ,
4169
4168
universeDomain : this . bucket . storage . universeDomain ,
4170
4169
[ 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
+ }
4172
4181
4173
4182
uploadStream
4174
4183
. on ( 'response' , resp => {
Original file line number Diff line number Diff line change @@ -1991,6 +1991,25 @@ describe('File', () => {
1991
1991
writable . write ( 'data' ) ;
1992
1992
} ) ;
1993
1993
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
+
1994
2013
it ( 'should emit progress via resumable upload' , done => {
1995
2014
const progress = { } ;
1996
2015
You can’t perform that action at this time.
0 commit comments