diff --git a/lib/browser/object.js b/lib/browser/object.js index 790f9f668..15f312f72 100644 --- a/lib/browser/object.js +++ b/lib/browser/object.js @@ -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 { diff --git a/test/browser/browser.test.js b/test/browser/browser.test.js index d67e3cab6..43d02c059 100644 --- a/test/browser/browser.test.js +++ b/test/browser/browser.test.js @@ -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', () => {