Use === instead of == for END_OF_FILE compares
This caused a very hard to track down bug. Thanks to Mikeal Rogers for this fix. Unfortunately we were unable to put together a test case.
This commit is contained in:
parent
a98d23d905
commit
71dc232f93
@ -382,7 +382,7 @@ Object.defineProperty(Stream.prototype, 'readyState', {
|
||||
Stream.prototype.write = function (data, encoding) {
|
||||
if (this._writeQueue && this._writeQueue.length) {
|
||||
// Slow. There is already a write queue, so let's append to it.
|
||||
if (this._writeQueueLast() == END_OF_FILE) {
|
||||
if (this._writeQueueLast() === END_OF_FILE) {
|
||||
throw new Error('Stream.close() called already; cannot write.');
|
||||
}
|
||||
this._writeQueue.push(data); // TODO if string of the same encoding concat?
|
||||
@ -511,7 +511,7 @@ Stream.prototype.flush = function () {
|
||||
var data = this._writeQueue.shift();
|
||||
var encoding = this._writeQueueEncoding.shift();
|
||||
|
||||
if (data == END_OF_FILE) {
|
||||
if (data === END_OF_FILE) {
|
||||
this._shutdown();
|
||||
return true;
|
||||
}
|
||||
@ -714,7 +714,7 @@ Stream.prototype.close = function (data, encoding) {
|
||||
Stream.prototype.end = function (data, encoding) {
|
||||
if (this.writable) {
|
||||
if (data) this.write(data, encoding);
|
||||
if (this._writeQueueLast() != END_OF_FILE) {
|
||||
if (this._writeQueueLast() !== END_OF_FILE) {
|
||||
this._writeQueue.push(END_OF_FILE);
|
||||
this.flush();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user