Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser): put unhandle non-RequestTimeTooSkewed error #825

Merged
merged 1 commit into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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