From 7171bd6311f2511ed29de478a6788f739186e61b Mon Sep 17 00:00:00 2001 From: Brian White Date: Thu, 13 Oct 2016 18:02:52 -0400 Subject: [PATCH 1/5] timers: fix regression with clearImmediate() This commit fixes a regression introduced in 0ed8839a27 that caused additional queued immediate callbacks to be ignored if `clearImmediate(immediate)` was called within the callback for `immediate`. PR-URL: https://github.com/nodejs/node/pull/9086 Fixes: https://github.com/nodejs/node/issues/9084 Reviewed-By: Rich Trott Reviewed-By: Jeremiah Senkpiel Reviewed-By: James M Snell Reviewed-By: Evan Lucas --- lib/timers.js | 11 ++++++++++- test/parallel/test-timers-clearImmediate.js | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-timers-clearImmediate.js 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/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`); +}); From 8c4fab0a28edfe32c3e7305fe55f0a1bc5e3200d Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 14 Oct 2016 00:09:30 +0200 Subject: [PATCH 2/5] stream: fix `Writable` subclass instanceof checks 2a4b068acaa160 introduced a regression in where checking `instanceof` would fail for `Writable` subclasses inside the subclass constructor, i.e. before `Writable()` was called. Also, calling `null instanceof Writable` or `undefined instanceof Writable` would fail due to accessing the `_writableState` property of the target object. This fixes these problems. PR-URL: https://github.com/nodejs/node/pull/9088 Ref: https://github.com/nodejs/node/pull/8834#issuecomment-253640692 Reviewed-By: Ilkka Myller Reviewed-By: Jeremiah Senkpiel Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Evan Lucas --- lib/_stream_writable.js | 11 ++++++++--- test/parallel/test-stream-inheritance.js | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) 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/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/); From 8d2206fe41c902d9b6bac928049d2317f9965c7f Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 13 Oct 2016 07:38:38 +0000 Subject: [PATCH 3/5] build: add -DZLIB_CONST when building with --shared-zlib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 782620f added the define only when building with the bundled zlib. Using a shared zlib results in build breakage: ../src/inspector_agent.cc:179:16: error: assigning to 'Bytef *' (aka 'unsigned char *') from incompatible type 'const uint8_t *' (aka 'const unsigned char *') strm.next_in = PROTOCOL_JSON + 3; ^ ~~~~~~~~~~~~~~~~~ 1 error generated. PR-URL: https://github.com/nodejs/node/pull/9077 Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Myles Borins Reviewed-By: Johan Bergström Reviewed-By: Michael Dawson Reviewed-By: Evan Lucas --- node.gyp | 2 ++ 1 file changed, 2 insertions(+) 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"', { From c6a397bce63fc026421e1515b98eec9b8b5a8468 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Fri, 14 Oct 2016 16:35:36 -0500 Subject: [PATCH 4/5] 2016-10-14, Version 6.8.1 (Current) * build: Fix building with shared zlib. (Bradley T. Hughes) [#9077](https://github.com/nodejs/node/pull/9077) * stream: fix `Writable` subclass instanceof checks (Anna Henningsen) [#9088](https://github.com/nodejs/node/pull/9088) * timers: fix regression with clearImmediate() (Brian White) [#9086](https://github.com/nodejs/node/pull/9086) PR-URL: https://github.com/nodejs/node/pull/9104 --- CHANGELOG.md | 3 ++- doc/changelogs/CHANGELOG_V6.md | 16 ++++++++++++++++ src/node_version.h | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) 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.0
+6.8.1
+6.8.0
6.7.0
6.6.0
6.5.0
diff --git a/doc/changelogs/CHANGELOG_V6.md b/doc/changelogs/CHANGELOG_V6.md index 35b66dfcc1a52d..40d151223a0e2c 100644 --- a/doc/changelogs/CHANGELOG_V6.md +++ b/doc/changelogs/CHANGELOG_V6.md @@ -6,6 +6,7 @@ +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/src/node_version.h b/src/node_version.h index 3b61bb69ca8ec3..1e5ff21511437b 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -5,7 +5,7 @@ #define NODE_MINOR_VERSION 8 #define NODE_PATCH_VERSION 1 -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) From 4613c22b0069489585e4e3c8e0fd21e7bfda6ef5 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Fri, 14 Oct 2016 19:29:24 -0500 Subject: [PATCH 5/5] Working on v6.8.2 PR-URL: https://github.com/nodejs/node/pull/9104 --- src/node_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_version.h b/src/node_version.h index 1e5ff21511437b..9897b2bf19349e 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -3,9 +3,9 @@ #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 1 +#define NODE_VERSION_IS_RELEASE 0 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)