Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V11.5.0 proposal #25102

Merged
merged 89 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
022599c
tools: prepare tools/genv8constants.py for Python 3
Dec 3, 2018
a5c8af7
test: prepare test/message/testcfg.py for Python 3
Dec 3, 2018
a5c5786
test: refactor test-fs-write-file-sync.js
cjihrig Dec 4, 2018
8b109f0
process: simplify check in previousValueIsValid()
cjihrig Dec 4, 2018
5f60ed7
path: replace assertPath() with validator
cjihrig Dec 4, 2018
90d481e
src: remove unused env variables in node_util
danbev Dec 4, 2018
9b000e5
src: remove finalized_ member from Hash class
danbev Dec 4, 2018
c4f3cf9
doc: revise Waiting for Approvals documentation
Trott Dec 5, 2018
15632c3
tools: prepare tools/test.py for Python 3
Dec 3, 2018
526ff1d
test: prepare test/pseudo-tty/testcfg.py for Python 3
Dec 2, 2018
7cac76c
tools: prepare tools/specialize_node_d.py for Python 3
Dec 3, 2018
c3dda00
tools: prepare tools/js2c.py for Python 3
Dec 3, 2018
94d02ca
src: fix warning for potential snprintf truncation
sam-github Dec 3, 2018
5206f3a
src: do not alias new and old signal masks
sam-github Dec 3, 2018
c300aaa
doc: update LICENSE file
addaleax Dec 7, 2018
643ca14
doc: fix order of events when request is aborted
lpinca Dec 2, 2018
6db760c
test: improve test-net-socket-timeout
Trott Dec 5, 2018
3d87688
test: fix wrong parameter
zhmushan Dec 5, 2018
91ce957
test: make http2 timeout test robust
Trott Dec 6, 2018
592bad1
test: move http2 test to parallel
Trott Dec 6, 2018
f41443c
test: move test-cli-syntax to sequential
Trott Dec 8, 2018
81dce68
doc: update http doc for new Agent()/support options in socket.connect()
BeniCheni Dec 5, 2018
56b2a72
inspector: split the HostPort being used and the one parsed from CLI
joyeecheung Dec 1, 2018
cc8a805
build: fix compiler version detection
richardlau Dec 6, 2018
79c52a9
lib: improve error creation performance
BridgeAR Nov 18, 2018
2a11e6a
module: use validateString in modules/cjs
ZYSzys Dec 6, 2018
cda1da9
doc: update "Testing and CI" in Collaborator Guide
Trott Dec 7, 2018
ac46e27
tools: do not lint tools/inspector_protocol or tools/markupsafe
Dec 7, 2018
a6a3829
doc: simplify author ready
BridgeAR Dec 7, 2018
ad6104d
tools: update ESLint to 5.10.0
cjihrig Dec 8, 2018
e140d41
tools: capitalize sentences
BridgeAR Dec 3, 2018
1f61c89
tools: prepare tools/icu/icutrim.py for Python 3
Dec 7, 2018
25dae6c
module: use validateString in modules/esm
ZYSzys Dec 6, 2018
bf4faf3
assert,util: harden comparison
BridgeAR Dec 3, 2018
b60808a
tools: prepare tools/testp.py for Python 3
Dec 7, 2018
16a75be
tools: prepare ./tools/compress_json.py for Python 3
Dec 7, 2018
bc71e9e
test: prepare test/pseudo-tty/testcfg.py Python 3
Dec 7, 2018
56fd127
test: do not lint macros files (again)
Dec 7, 2018
22b6bef
test: mark test-cli-syntax as flaky/unreliable
Trott Dec 11, 2018
0220cd3
doc: remove bad link to irc info
richardlau Dec 11, 2018
08c6b21
src: use Local version of ToBoolean()
cjihrig Dec 9, 2018
9bfbb68
doc: add class worker documentation
yoshimoto8 Dec 5, 2018
e050a57
test: replace callback with arrows
Shubhamurkade Nov 27, 2018
d760572
src: remove use of CallOnForegroundThread()
cjihrig Dec 9, 2018
b2e6cbd
doc: update Useful CI Jobs section of Collaborator Guide
Trott Dec 9, 2018
39af61f
stream: fix end-of-stream for HTTP/2
addaleax Dec 9, 2018
016e352
test: test TLS client authentication
sam-github Oct 12, 2017
390e050
tls: support "BEGIN TRUSTED CERTIFICATE" for ca:
sam-github Nov 30, 2018
117e991
util: add inspection getter option
BridgeAR Dec 4, 2018
e61bbda
test: improve internet/test-dns
IlarionHalushka Dec 9, 2018
5a1289d
src: create env->inspector_console_api_object earlier
joyeecheung Dec 8, 2018
f854701
src: include node_internals.h in node_metadata.cc
danbev Dec 10, 2018
331f604
worker: drain messages from internal message port
yaelhe Dec 10, 2018
d366676
test: split test-cli-syntax into multiple tests
Trott Dec 9, 2018
1e09629
doc: fix author-ready conflict
BridgeAR Dec 13, 2018
649a728
test: from functools import reduce in test/testpy/__init__.py
Dec 11, 2018
f0bcacd
doc: update a link of npm repository
watilde Dec 11, 2018
877f8a0
doc: revise internal vs. public API in Collaborator Guide
Trott Dec 11, 2018
d5b0ce1
test: refactor test-enable-in-init
Dec 12, 2018
dbdea36
doc: add codebytere's info to release team
codebytere Dec 13, 2018
d0270f3
src: add GetLoadedLibraries routine
gireeshpunathil Dec 4, 2018
5f8950b
src: emit 'params' instead of 'data' for NodeTracing.dataCollected
kjin Dec 10, 2018
f43f45a
process: properly close file descriptor on exit
BridgeAR Dec 11, 2018
900a412
test: increase error information in test-cli-syntax-*
Trott Dec 13, 2018
a4ef54a
test: mark test-child-process-execsync flaky on AIX
Trott Dec 14, 2018
9bd4267
test: mark test-cli-node-options flaky on arm
Trott Dec 14, 2018
2456a54
lib: ensure readable stream flows to end
Rantanen Dec 9, 2018
e7b77ea
url: remove an eslint-disable comment
cjihrig Dec 12, 2018
2825894
test: mark test-worker-memory flaky on Windows CI
Trott Dec 14, 2018
da984be
test: remove reference to whatwg in file names under test/wpt
joyeecheung Dec 4, 2018
7e0dbc6
test: improve WPT runner name matching
joyeecheung Nov 18, 2018
1e3fb0a
test: mark test-child-process-exit-code flaky
Trott Dec 14, 2018
ac919ef
test: mark test-child-process-execfile flaky
Trott Dec 14, 2018
a1f0da1
util: remove todo
BridgeAR Dec 12, 2018
eb9e6e6
test: adding history regression test case
antsmartian Dec 13, 2018
e04e854
test: use blocks instead of async IIFE
addaleax Dec 12, 2018
d449c36
stream: re-use existing `once()` implementation
addaleax Dec 12, 2018
302081b
build: make lint-addon-docs run only if needed
danbev Dec 12, 2018
110fd39
test: remove dead code
BridgeAR Dec 13, 2018
ddff644
test: run eslint on test file and fix errors
BridgeAR Dec 13, 2018
ab1801b
test: use global.gc() instead of gc()
cjihrig Dec 13, 2018
4f0d17b
test: remove unnecessary linter comment
cjihrig Dec 13, 2018
f4d5c35
net: use strict comparisons for fd
cjihrig Dec 13, 2018
00ce972
doc: make README formatting more consistent
yewenjunfighting Dec 13, 2018
a9f239f
doc: add EventTarget link to worker_threads
Azard Dec 15, 2018
5931747
util: inspect all prototypes
BridgeAR Dec 11, 2018
bde5df2
doc: fix node.1 --http-parser sort order
cjihrig Dec 14, 2018
2e94f3b
querystring: remove eslint-disable
cjihrig Dec 12, 2018
9a5b243
2018-12-18, Version 11.5.0 (Current)
BethGriggs Dec 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stream: fix end-of-stream for HTTP/2
HTTP/2 streams call `.end()` on themselves from their
`.destroy()` method, which might be queued (e.g. due to network
congestion) and not processed before the stream itself is destroyed.

In that case, the `_writableState.ended` property could be set before
the stream emits its `'close'` event, and never actually emits the
`'finished'` event, confusing the end-of-stream implementation so
that it wouldn’t call its callback.

This can be fixed by watching for the end events themselves using the
existing `'finish'` and `'end'` listeners rather than relying on the
`.ended` properties of the `_...State` objects.

These properties still need to be checked to know whether stream
closure was premature – My understanding is that ideally, streams
should not emit `'close'` before `'end'` and/or `'finished'`, so this
might be another bug, but changing this would require modifying tests
and almost certainly be a breaking change.

Fixes: #24456

PR-URL: #24926
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
  • Loading branch information
addaleax authored and BethGriggs committed Dec 17, 2018
commit 39af61faa2c07e59c36000d860a07ee7963cc420
21 changes: 14 additions & 7 deletions lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ function eos(stream, opts, callback) {

callback = once(callback);

const ws = stream._writableState;
const rs = stream._readableState;
let readable = opts.readable || (opts.readable !== false && stream.readable);
let writable = opts.writable || (opts.writable !== false && stream.writable);

const onlegacyfinish = () => {
if (!stream.writable) onfinish();
};

var writableEnded = stream._writableState && stream._writableState.finished;
const onfinish = () => {
writable = false;
writableEnded = true;
if (!readable) callback.call(stream);
};

var readableEnded = stream._readableState && stream._readableState.endEmitted;
const onend = () => {
readable = false;
readableEnded = true;
if (!writable) callback.call(stream);
};

Expand All @@ -60,11 +62,16 @@ function eos(stream, opts, callback) {
};

const onclose = () => {
if (readable && !(rs && rs.ended)) {
return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE());
let err;
if (readable && !readableEnded) {
if (!stream._readableState || !stream._readableState.ended)
err = new ERR_STREAM_PREMATURE_CLOSE();
return callback.call(stream, err);
}
if (writable && !(ws && ws.ended)) {
return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE());
if (writable && !writableEnded) {
if (!stream._writableState || !stream._writableState.ended)
err = new ERR_STREAM_PREMATURE_CLOSE();
return callback.call(stream, err);
}
};

Expand All @@ -77,7 +84,7 @@ function eos(stream, opts, callback) {
stream.on('abort', onclose);
if (stream.req) onrequest();
else stream.on('request', onrequest);
} else if (writable && !ws) { // legacy streams
} else if (writable && !stream._writableState) { // legacy streams
stream.on('end', onlegacyfinish);
stream.on('close', onlegacyfinish);
}
Expand Down
2 changes: 0 additions & 2 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ test-net-connect-options-port: PASS,FLAKY
test-http2-pipe: PASS,FLAKY
test-worker-syntax-error: PASS,FLAKY
test-worker-syntax-error-file: PASS,FLAKY
# https://github.com/nodejs/node/issues/24456
test-stream-pipeline-http2: PASS,FLAKY

[$system==linux]

Expand Down
39 changes: 39 additions & 0 deletions test/parallel/test-stream-pipeline-queued-end-in-destroy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { Readable, Duplex, pipeline } = require('stream');

// Test that the callback for pipeline() is called even when the ._destroy()
// method of the stream places an .end() request to itself that does not
// get processed before the destruction of the stream (i.e. the 'close' event).
// Refs: https://github.com/nodejs/node/issues/24456

const readable = new Readable({
read: common.mustCall(() => {})
});

const duplex = new Duplex({
write(chunk, enc, cb) {
// Simulate messages queueing up.
},
read() {},
destroy(err, cb) {
// Call end() from inside the destroy() method, like HTTP/2 streams
// do at the time of writing.
this.end();
cb(err);
}
});

duplex.on('finished', common.mustNotCall());

pipeline(readable, duplex, common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE');
}));

// Write one chunk of data, and destroy the stream later.
// That should trigger the pipeline destruction.
readable.push('foo');
setImmediate(() => {
readable.destroy();
});