File tree 2 files changed +11
-7
lines changed
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,10 @@ proto.requestError = async function requestError(result) {
341
341
err . code = info . Code ;
342
342
err . requestId = info . RequestId ;
343
343
err . hostId = info . HostId ;
344
+ // https://help.aliyun.com/zh/oss/support/http-status-code-409#section-rmc-hvd-j38
345
+ if ( info . Code === 'PositionNotEqualToLength' && result . headers && result . headers [ 'x-oss-next-append-position' ] ) {
346
+ err . nextAppendPosition = result . headers [ 'x-oss-next-append-position' ] ;
347
+ }
344
348
}
345
349
346
350
debug ( 'generate error %j' , err ) ;
Original file line number Diff line number Diff line change @@ -2075,13 +2075,13 @@ describe('test/object.test.js', () => {
2075
2075
it ( 'should error when positio not match' , async ( ) => {
2076
2076
await store . append ( name , Buffer . from ( 'foo' ) ) ;
2077
2077
2078
- try {
2079
- await store . append ( name , Buffer . from ( 'foo' ) ) ;
2080
- throw new Error ( 'should not run' ) ;
2081
- } catch ( err ) {
2082
- assert ( err . message === 'Position is not equal to file length' ) ;
2083
- assert ( err . name === 'PositionNotEqualToLengthError' ) ;
2084
- }
2078
+ await assert . rejects (
2079
+ store . append ( name , Buffer . from ( 'foo' ) ) ,
2080
+ err =>
2081
+ err . message === 'Position is not equal to file length' &&
2082
+ err . name === 'PositionNotEqualToLengthError' &&
2083
+ err . nextAppendPosition === '3'
2084
+ ) ;
2085
2085
} ) ;
2086
2086
2087
2087
it ( 'should use nextAppendPosition to append next' , async ( ) => {
You can’t perform that action at this time.
0 commit comments