diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0254a78aede3da..0a986966019a42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,7 +26,8 @@ release.
+6.8.1
6.8.0
6.7.0
6.6.0
@@ -34,6 +35,21 @@
[Node.js Long Term Support plan](https://github.com/nodejs/LTS) starting in
October 2016.
+
+## 2016-10-14, Version 6.8.1 (Current), @evanlucas
+
+### Notable changes
+
+* **build**: Fix building with shared zlib. (Bradley T. Hughes) [#9077](https://github.com/nodejs/node/pull/9077)
+* **stream**: Fix regression in `stream.Writable` subclass `instanceof` checks. (Anna Henningsen) [#9088](https://github.com/nodejs/node/pull/9088)
+* **timers**: Fix regression where immediates that are cleared in the callback would never be called. (Brian White) [#9086](https://github.com/nodejs/node/pull/9086)
+
+### Commits
+
+* [[`8d2206fe41`](https://github.com/nodejs/node/commit/8d2206fe41)] - **build**: add -DZLIB_CONST when building with --shared-zlib (Bradley T. Hughes) [#9077](https://github.com/nodejs/node/pull/9077)
+* [[`8c4fab0a28`](https://github.com/nodejs/node/commit/8c4fab0a28)] - **stream**: fix `Writable` subclass instanceof checks (Anna Henningsen) [#9088](https://github.com/nodejs/node/pull/9088)
+* [[`7171bd6311`](https://github.com/nodejs/node/commit/7171bd6311)] - **timers**: fix regression with clearImmediate() (Brian White) [#9086](https://github.com/nodejs/node/pull/9086)
+
## 2016-10-12, Version 6.8.0 (Current), @Fishrock123
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index f6c970e04dd6b5..575c56cdd7c712 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -141,9 +141,10 @@ if (typeof Symbol === 'function' && Symbol.hasInstance) {
realHasInstance = Function.prototype[Symbol.hasInstance];
Object.defineProperty(Writable, Symbol.hasInstance, {
value: function(object) {
- // Trying to move the `realHasInstance` from the Writable constructor
- // to here will break the Node.js LazyTransform implementation.
- return object._writableState instanceof WritableState;
+ if (realHasInstance.call(this, object))
+ return true;
+
+ return object && object._writableState instanceof WritableState;
}
});
} else {
@@ -156,6 +157,10 @@ function Writable(options) {
// Writable ctor is applied to Duplexes, too.
// `realHasInstance` is necessary because using plain `instanceof`
// would return false, as no `_writableState` property is attached.
+
+ // Trying to use the custom `instanceof` for Writable here will also break the
+ // Node.js LazyTransform implementation, which has a non-trivial getter for
+ // `_writableState` that would lead to infinite recursion.
if (!(realHasInstance.call(Writable, this)) &&
!(this instanceof Stream.Duplex)) {
return new Writable(options);
diff --git a/lib/timers.js b/lib/timers.js
index d247c4001c0921..78953f25d5a17e 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -575,12 +575,21 @@ function processImmediate() {
domain.enter();
immediate._callback = immediate._onImmediate;
+
+ // Save next in case `clearImmediate(immediate)` is called from callback
+ var next = immediate._idleNext;
+
tryOnImmediate(immediate, tail);
if (domain)
domain.exit();
- immediate = immediate._idleNext;
+ // If `clearImmediate(immediate)` wasn't called from the callback, use the
+ // `immediate`'s next item
+ if (immediate._idleNext)
+ immediate = immediate._idleNext;
+ else
+ immediate = next;
}
// Only round-trip to C++ land if we have to. Calling clearImmediate() on an
diff --git a/node.gyp b/node.gyp
index 4043269930da27..b686788a823c5f 100644
--- a/node.gyp
+++ b/node.gyp
@@ -477,6 +477,8 @@
}],
[ 'node_shared_zlib=="false"', {
'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
+ }, {
+ 'defines': [ 'ZLIB_CONST' ],
}],
[ 'node_shared_http_parser=="false"', {
diff --git a/src/node_version.h b/src/node_version.h
index 3b61bb69ca8ec3..9897b2bf19349e 100644
--- a/src/node_version.h
+++ b/src/node_version.h
@@ -3,7 +3,7 @@
#define NODE_MAJOR_VERSION 6
#define NODE_MINOR_VERSION 8
-#define NODE_PATCH_VERSION 1
+#define NODE_PATCH_VERSION 2
#define NODE_VERSION_IS_RELEASE 0
diff --git a/test/parallel/test-stream-inheritance.js b/test/parallel/test-stream-inheritance.js
index efc28731bd0c36..77dc4804c1f986 100644
--- a/test/parallel/test-stream-inheritance.js
+++ b/test/parallel/test-stream-inheritance.js
@@ -27,3 +27,19 @@ assert.ok(!(readable instanceof Transform));
assert.ok(!(writable instanceof Transform));
assert.ok(!(duplex instanceof Transform));
assert.ok(transform instanceof Transform);
+
+assert.ok(!(null instanceof Writable));
+assert.ok(!(undefined instanceof Writable));
+
+// Simple inheritance check for `Writable` works fine in a subclass constructor.
+function CustomWritable() {
+ assert.ok(this instanceof Writable, 'inherits from Writable');
+ assert.ok(this instanceof CustomWritable, 'inherits from CustomWritable');
+}
+
+Object.setPrototypeOf(CustomWritable, Writable);
+Object.setPrototypeOf(CustomWritable.prototype, Writable.prototype);
+
+new CustomWritable();
+
+assert.throws(CustomWritable, /AssertionError: inherits from Writable/);
diff --git a/test/parallel/test-timers-clearImmediate.js b/test/parallel/test-timers-clearImmediate.js
new file mode 100644
index 00000000000000..ab65b7bf1ce05d
--- /dev/null
+++ b/test/parallel/test-timers-clearImmediate.js
@@ -0,0 +1,18 @@
+'use strict';
+require('../common');
+const assert = require('assert');
+
+const N = 3;
+var count = 0;
+function next() {
+ const immediate = setImmediate(function() {
+ clearImmediate(immediate);
+ ++count;
+ });
+}
+for (var i = 0; i < N; ++i)
+ next();
+
+process.on('exit', () => {
+ assert.strictEqual(count, N, `Expected ${N} immediate callback executions`);
+});
|