Skip to content

Commit e7df8a5

Browse files
authored
fix: check if .destroy exists
Node 8 has it, but Node 6 does not have that method.
1 parent a594e2b commit e7df8a5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/volume.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ FsReadStream.prototype.open = function() {
21642164
this._vol.open(this.path, this.flags, this.mode, function(er, fd) {
21652165
if (er) {
21662166
if (self.autoClose) {
2167-
self.destroy();
2167+
if(self.destroy) self.destroy();
21682168
}
21692169
self.emit('error', er);
21702170
return;
@@ -2218,7 +2218,7 @@ FsReadStream.prototype._read = function(n) {
22182218

22192219
function onread(er, bytesRead) {
22202220
if (er) {
2221-
if (self.autoClose) {
2221+
if (self.autoClose && self.destroy) {
22222222
self.destroy();
22232223
}
22242224
self.emit('error', er);
@@ -2334,7 +2334,7 @@ function FsWriteStream(vol, path, options) {
23342334
FsWriteStream.prototype.open = function() {
23352335
this._vol.open(this.path, this.flags, this.mode, function(er, fd) {
23362336
if (er) {
2337-
if (this.autoClose) {
2337+
if (this.autoClose && this.destroy) {
23382338
this.destroy();
23392339
}
23402340
this.emit('error', er);
@@ -2359,7 +2359,7 @@ FsWriteStream.prototype._write = function(data, encoding, cb) {
23592359
var self = this;
23602360
this._vol.write(this.fd, data, 0, data.length, this.pos, function(er, bytes) {
23612361
if (er) {
2362-
if (self.autoClose) {
2362+
if (self.autoClose && self.destroy) {
23632363
self.destroy();
23642364
}
23652365
return cb(er);
@@ -2394,7 +2394,7 @@ FsWriteStream.prototype._writev = function(data, cb) {
23942394
const buf = Buffer.concat(chunks);
23952395
this._vol.write(this.fd, buf, 0, buf.length, this.pos, (er, bytes) => {
23962396
if (er) {
2397-
self.destroy();
2397+
if(self.destroy) self.destroy();
23982398
return cb(er);
23992399
}
24002400
self.bytesWritten += bytes;

0 commit comments

Comments
 (0)