@azure/storage-blob
Advanced tools
Comparing version 12.4.1-alpha.20210126.1 to 12.4.1-alpha.20210128.1
@@ -6,2 +6,3 @@ # Release History | ||
- Fixed a compile failure due to "Can't resolve 'crypto'" in Angular. [Issue #13267](https://github.com/Azure/azure-sdk-for-js/issues/13267). | ||
- Fixed an issue that the download stream returned by `BlobClient.download` won't release underlying resources unless it's fully consumed. [Isssue #11850](https://github.com/Azure/azure-sdk-for-js/issues/11850). | ||
- Fixed an error when listing blob with a metadata key of `_` [issue #9197](https://github.com/Azure/azure-sdk-for-js/issues/9171) | ||
@@ -8,0 +9,0 @@ - The `"Unclosed root tag"` XML parser error is now retriable. [PR #13076](https://github.com/Azure/azure-sdk-for-js/pull/13076). |
@@ -5,4 +5,2 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
import { Readable } from "stream"; | ||
import { AbortSignal, AbortError } from "@azure/abort-controller"; | ||
var ABORT_ERROR = new AbortError("The operation was aborted."); | ||
/** | ||
@@ -31,32 +29,5 @@ * ONLY AVAILABLE IN NODE.JS RUNTIME. | ||
if (options === void 0) { options = {}; } | ||
var _this = _super.call(this) || this; | ||
var _this = _super.call(this, { highWaterMark: options.highWaterMark }) || this; | ||
_this.retries = 0; | ||
_this.abortHandler = function () { | ||
_this.source.pause(); | ||
_this.emit("error", ABORT_ERROR); | ||
}; | ||
_this.aborter = options.abortSignal || AbortSignal.none; | ||
_this.getter = getter; | ||
_this.source = source; | ||
_this.start = offset; | ||
_this.offset = offset; | ||
_this.end = offset + count - 1; | ||
_this.maxRetryRequests = | ||
options.maxRetryRequests && options.maxRetryRequests >= 0 ? options.maxRetryRequests : 0; | ||
_this.onProgress = options.onProgress; | ||
_this.options = options; | ||
_this.aborter.addEventListener("abort", _this.abortHandler); | ||
_this.setSourceDataHandler(); | ||
_this.setSourceEndHandler(); | ||
_this.setSourceErrorHandler(); | ||
return _this; | ||
} | ||
RetriableReadableStream.prototype._read = function () { | ||
if (!this.aborter.aborted) { | ||
this.source.resume(); | ||
} | ||
}; | ||
RetriableReadableStream.prototype.setSourceDataHandler = function () { | ||
var _this = this; | ||
this.source.on("data", function (data) { | ||
_this.sourceDataHandler = function (data) { | ||
if (_this.options.doInjectErrorOnce) { | ||
@@ -79,14 +50,15 @@ _this.options.doInjectErrorOnce = undefined; | ||
} | ||
}); | ||
}; | ||
RetriableReadableStream.prototype.setSourceEndHandler = function () { | ||
var _this = this; | ||
this.source.on("end", function () { | ||
}; | ||
_this.sourceErrorOrEndHandler = function (err) { | ||
if (err && err.name === "AbortError") { | ||
_this.destroy(err); | ||
return; | ||
} | ||
// console.log( | ||
// `Source stream emits end, offset: ${ | ||
// `Source stream emits end or error, offset: ${ | ||
// this.offset | ||
// }, dest end : ${this.end}` | ||
// ); | ||
_this.removeSourceEventHandlers(); | ||
if (_this.offset - 1 === _this.end) { | ||
_this.aborter.removeEventListener("abort", _this.abortHandler); | ||
_this.push(null); | ||
@@ -103,12 +75,10 @@ } | ||
_this.source = newSource; | ||
_this.setSourceDataHandler(); | ||
_this.setSourceEndHandler(); | ||
_this.setSourceErrorHandler(); | ||
_this.setSourceEventHandlers(); | ||
}) | ||
.catch(function (error) { | ||
_this.emit("error", error); | ||
_this.destroy(error); | ||
}); | ||
} | ||
else { | ||
_this.emit("error", new Error( | ||
_this.destroy(new Error( | ||
// tslint:disable-next-line:max-line-length | ||
@@ -120,12 +90,36 @@ "Data corruption failure: received less data than required and reached maxRetires limitation. Received data offset: " + (_this | ||
else { | ||
_this.emit("error", new Error("Data corruption failure: Received more data than original request, data needed offset is " + _this.end + ", received offset: " + (_this.offset - 1))); | ||
_this.destroy(new Error("Data corruption failure: Received more data than original request, data needed offset is " + _this.end + ", received offset: " + (_this.offset - 1))); | ||
} | ||
}); | ||
}; | ||
_this.getter = getter; | ||
_this.source = source; | ||
_this.start = offset; | ||
_this.offset = offset; | ||
_this.end = offset + count - 1; | ||
_this.maxRetryRequests = | ||
options.maxRetryRequests && options.maxRetryRequests >= 0 ? options.maxRetryRequests : 0; | ||
_this.onProgress = options.onProgress; | ||
_this.options = options; | ||
_this.setSourceEventHandlers(); | ||
return _this; | ||
} | ||
RetriableReadableStream.prototype._read = function () { | ||
this.source.resume(); | ||
}; | ||
RetriableReadableStream.prototype.setSourceErrorHandler = function () { | ||
var _this = this; | ||
this.source.on("error", function (error) { | ||
_this.emit("error", error); | ||
}); | ||
RetriableReadableStream.prototype.setSourceEventHandlers = function () { | ||
this.source.on("data", this.sourceDataHandler); | ||
this.source.on("end", this.sourceErrorOrEndHandler); | ||
this.source.on("error", this.sourceErrorOrEndHandler); | ||
}; | ||
RetriableReadableStream.prototype.removeSourceEventHandlers = function () { | ||
this.source.removeListener("data", this.sourceDataHandler); | ||
this.source.removeListener("end", this.sourceErrorOrEndHandler); | ||
this.source.removeListener("error", this.sourceErrorOrEndHandler); | ||
}; | ||
RetriableReadableStream.prototype._destroy = function (error, callback) { | ||
// remove listener from source and release source | ||
this.removeSourceEventHandlers(); | ||
this.source.destroy(); | ||
callback(error === null ? undefined : error); | ||
}; | ||
return RetriableReadableStream; | ||
@@ -132,0 +126,0 @@ }(Readable)); |
{ | ||
"name": "@azure/storage-blob", | ||
"sdk-type": "client", | ||
"version": "12.4.1-alpha.20210126.1", | ||
"version": "12.4.1-alpha.20210128.1", | ||
"description": "Microsoft Azure Storage SDK for JavaScript - Blob", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
6299844
77154