Skip to content

Commit

Permalink
fix(browser): put unhandle non-RequestTimeTooSkewed error
Browse files Browse the repository at this point in the history
  • Loading branch information
weiyie committed Jul 3, 2020
1 parent 4b8edf6 commit 5a80cac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/browser/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ proto.put = async function put(name, file, options) {
if (err.code === 'RequestTimeTooSkewed') {
this.options.amendTimeSkewed = +new Date(err.serverTime) - new Date();
return await this.put(name, file, options);
} else {
throw err;
}
}
} else {
Expand Down
19 changes: 19 additions & 0 deletions test/browser/browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,25 @@ describe('browser', () => {
assert(true);
}
});

it('should throw ConnectionTimeoutError when putstream timeout', async () => {
const name = `${prefix}put/test`;
const content = Array(1024 * 1024 * 10).fill(1).join('');
const body = new Blob([content], { type: 'text/plain' });
const options = {
timeout: 300
};
try {
setTimeout(() => {
options.timeout = 60000;
}, 200);
await store.put(name, body, options);
assert(false);
} catch (error) {
assert(error.name === 'ConnectionTimeoutError');
}
});

});

describe('test-content-type', () => {
Expand Down

0 comments on commit 5a80cac

Please sign in to comment.