Comments (15)
This doesn't happen with uploadFileToBlockBlob btw.
from azure-storage-js.
@Ventis This is a bug in RetriableReadableStream
which used by blockBlobURL.download
. RetriableReadableStream
is referenced by the aborter timer cannot be GCed.
Before we have a fix, you can manually cancel the Aborter timer when you finish the download by:
aborter.cancelTimer()
.
from azure-storage-js.
We had this issue on reading that the Aborter timer would not be cleared; and since the try catch around our filesystem methods would not catch the internal errors thrown inside the Aborter's timeout we handled the timeout ourself, like so:
// example filesystem
class FileSystem {
private aborterTimeoutSeconds: number = 60
public async read(filePath: string): Promise<Readable> {
const blobUrl = this.getBlobUrl(filePath)
return new Promise<Readable>(async (resolve, reject) => {
try {
const { aborter, clearAborterTimer } = this.getNewAborter(reject)
const downloadBlockBlobResponse = await blobUrl.download(aborter, 0)
downloadBlockBlobResponse.readableStreamBody.on('end', () => {
clearAborterTimer()
})
// Use PassThrough to turn the original stream into Readable
const passthrough = new PassThrough()
downloadBlockBlobResponse.readableStreamBody.pipe(passthrough)
resolve(passthrough)
} catch (e) {
reject(e)
}
})
}
private getNewAborter(reject: Function) {
const aborter = Aborter.none
const timer = setTimeout(() => {
try {
aborter.abort()
} catch (err) {
reject(err)
}
}, this.aborterTimeoutSeconds * 1000)
const clearAborterTimer = () => {
clearTimeout(timer)
}
return {
aborter,
clearAborterTimer,
}
}
}
Hope this helps someone that had a similar issue.
from azure-storage-js.
It is happenning in uploadStreamToBlockBlob too. I'm using version 10.3.0
from azure-storage-js.
aborter.cancelTimer()
worked for me
from azure-storage-js.
Unfortunately for Typescript users cancelTimer() is a private method of Aborter class, so this "hack" is needed :
Aborter.prototype['cancelTimer'].apply(aborter);
from azure-storage-js.
Then we need to make cancelTimer
to public
from azure-storage-js.
This is fixed in 10.4.0, see https://www.npmjs.com/package/@azure/storage-blob
from azure-storage-js.
@XiaoningLiu did you patch the Typescript for bringing public cancelTimer
? I'm using the release 10.5, but it seems still marked as private.
from azure-storage-js.
@highfield We do not need to call cancelTimer
as SDK fixed the issue and will not throw timeout error after download success.
from azure-storage-js.
@XiaoningLiu I wish to believe you, but I had the same problem as described above. Just after a short time the error crashed my app. That was yesterday afternoon.
Once I added the below workaround, the things seem going fine (no error after 12 hours):
const aborter = Aborter.timeout(30 * ONE_MINUTE);
const blockBlobURL = BlockBlobURL.fromContainerURL(this.containerURL, actualPath);
const response = await blockBlobURL.download(aborter, 0);
(aborter as any).cancelTimer(); // this makes the app working fine
return response.readableStreamBody as stream.Readable;
from azure-storage-js.
@highfield Sorry for that. Please leverage the workaround temporiaily.
@ljian3377 Can you help quick check this issue still reproduable in latest v10 & v12 blob package versions?
from azure-storage-js.
@highfield Sorry for that. Please leverage the workaround temporiaily.
@ljian3377 Can you help quick check this issue still reproduable in latest v10 & v12 blob package versions?
Reproduced in 10.3 and 10.4, but not in v12.
It seems to be fixed in @azure/storage-blob version: 12.0.0. And the API has some changes. Aborter
now goes in AbortController
. And blockBlobURL
basically is replaced by BlockBlobClient
.
Code snippet used to reproduce in v12:
const downloadBlockBlobResponse: BlobDownloadResponseModel = await blockBlobClient.download(0, undefined, { abortSignal: AbortController.timeout(60000) });
setTimeout(()=>console.log("wait done"), 100000);
from azure-storage-js.
I know this repo is no longer maintained
But mentioning it in this issue because I found how to fix this bug here
Reproduced in 10.3 and 10.4, but not in v12.
It seems to be fixed in @azure/storage-blob version: 12.0.0. And the API has some changes.Aborter
now goes inAbortController
. AndblockBlobURL
basically is replaced byBlockBlobClient
.Code snippet used to reproduce in v12:
const downloadBlockBlobResponse: BlobDownloadResponseModel = await blockBlobClient.download(0, undefined, { abortSignal: AbortController.timeout(60000) }); setTimeout(()=>console.log("wait done"), 100000);
I reproduced this bug in @azure/storage-blob version: 12.0.0 and 12.1.2 using the code snippet provided by @ljian3377
So I used the workaround provided to fix the issue
Aborter.prototype['cancelTimer'].apply(aborter);
from azure-storage-js.
@Mitsuo-Yoshida
That's wierd. I still can't reproduce it. Could you please share more information of your reproduction? What envirornment?
Has the download completed when the timeout aborter aborts?
from azure-storage-js.
Related Issues (20)
- This repo is missing important files HOT 1
- high-level samples Abort.timeout duration HOT 2
- can I use this library in a React Native app? HOT 10
- Missing setProperties function for blob HOT 2
- Export RetryPolicyType in index.ts HOT 1
- Unable to set file HTTP headers HOT 1
- Using application/json header for file upload (x-ms-blob-type error) HOT 2
- Support for Angular4 (Typescript < 2.4) HOT 4
- how to handle viewing files that are stored in azure storage with multiple mime types HOT 7
- Cannot find name 'Event' HOT 9
- Aborter does not abort uploads that are in timeout / retrying HOT 2
- Gracefully handle 404 of reading from blob HOT 2
- [Tests] incorrect assert.ok() on result from string.indexof HOT 1
- downloadBlobToBuffer may download error ranges when customize non zero offset with count HOT 1
- Dowloading a blob should not reject on 304 HOT 3
- Question: file service API is so confusing :( :( HOT 2
- [Notice] This Project has been Moved to Azure SDK Central Repository
- How to list blobs from virtual directory in latest nodejs SDK? HOT 2
- How to get Content-MD5 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-storage-js.