Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
4a077cc
deps: backport 7c3748a from upstream V8
cristiancavalli Jan 18, 2017
9b35715
build: don't squash signal handlers with --shared
Dec 30, 2016
6e8edf9
crypto: fix handling of root_cert_store.
agl Oct 30, 2016
01280a0
src: fix memory leak introduced in 34febfbf4
bnoordhuis Nov 14, 2016
a118bb8
src: use ABORT() macro instead of abort()
evanlucas Nov 15, 2016
6fa3c73
crypto: use CHECK_NE instead of ABORT or abort
sam-github Dec 22, 2016
3b11d89
test: exclude pseudo-tty test pertinent to #11541
gireeshpunathil Feb 28, 2017
94964d0
constants: define ENGINE_METHOD_RSA
sam-github Feb 27, 2016
98d6b3f
doc: correct name of engine methods
sam-github Jan 25, 2017
b264cf2
http: reject control characters in http.request()
bnoordhuis Oct 4, 2016
67f7281
test: simplify test-http-client-unescaped-path
rvagg Nov 17, 2016
756cc91
build: Don't regenerate node symlink
Nov 28, 2016
aff1a92
build: fix node_g target
danbev Dec 6, 2016
c82e5b2
doc: improve rinfo object documentation
Dec 1, 2016
61a0e9e
doc: update LTS info for current releases
evanlucas Jan 10, 2017
a2cf0cb
doc: "s/git apply/git am -3" in V8 guide
MylesBorins Jan 6, 2017
b2da62f
doc: add test naming information to guide
Trott Jan 3, 2017
aa6320f
doc: sort require statements in tests
sam-github Jan 4, 2017
a88aa0b
doc: add links for zlib convenience methods
addaleax Jan 16, 2017
3272eec
doc: clarifying variables in fs.write()
jalafel Nov 24, 2016
3a72096
doc: add edsadr to collaborators
edsadr Jan 18, 2017
d488813
doc: add TimothyGu to collaborators
TimothyGu Jan 22, 2017
7d3001d
doc: update AUTHORS list to fix name
Jan 22, 2017
6deb562
test: refactor test-https-truncate
Trott Dec 11, 2016
7d71316
lib,src: support values > 4GB in heap statistics
bnoordhuis Dec 8, 2016
0db73fd
doc: update TheAlphaNerd to MylesBorins
MylesBorins Jan 3, 2017
33a3861
assert: update comments
Jan 2, 2017
deaf3f6
benchmark: improve readability of net benchmarks
mscdex Dec 25, 2016
71ae03b
meta: decharter the http working group
jasnell Jan 4, 2017
7d0f808
net: prefer === to ==
notarseniy Feb 22, 2017
f16dd61
doc: document clientRequest.aborted
zbjornson Feb 24, 2017
67a6b13
test: favor assertions over console logging
Trott Feb 25, 2017
4403975
doc: argument types for assert methods
ameliavoncat Feb 25, 2017
e95d87f
assert: apply minor refactoring
Trott Feb 22, 2017
d481996
test: fix flaky test-vm-timeout-rethrow
kunalspathak Feb 24, 2017
4af3da9
doc: note message event listeners ref IPC channels
DiegoRBaquero Feb 22, 2017
e2af074
test: throw check in test-zlib-write-after-close
Feb 21, 2017
df5f7d4
build: fail on CI if leftover processes
Trott Feb 9, 2017
eb8d406
src: update http-parser link
danbev Feb 21, 2017
b3c6d97
build: fix newlines in addon build output
mscdex Feb 20, 2017
0479885
tty: avoid oob warning in TTYWrap::GetWindowSize()
reklatsmasters Feb 18, 2017
6ed16c6
tls: do not crash on STARTTLS when OCSP requested
indutny Jan 9, 2017
69a423b
benchmark: add dgram bind(+/- params) benchmark
vsemozhetbyt Feb 11, 2017
5ac7be8
test: add regex check to test-module-loading
tarang9211 Feb 16, 2017
ebb3a09
doc: add comment for net.Server's error event
jjqq2013 Feb 12, 2017
4a642b9
test: improve coverage in test-crypto.dh
ejc-main Feb 9, 2017
a7d5edb
test: refactor test-http-response-splitting
notarseniy Feb 16, 2017
6316e53
child_process: refactor internal/child_process.js
notarseniy Feb 14, 2017
ab982e7
child_process: remove empty if condition
cjihrig Feb 16, 2017
769a737
test: remove unused args and comparison fix
sashashakun Feb 14, 2017
d13e043
doc: add STYLE_GUIDE (moved from nodejs/docs)
gibfahn Feb 12, 2017
7fce8f8
doc: change STYLE-GUIDE to STYLE_GUIDE
Dean-Coakley Feb 20, 2017
936d6f2
tools: suggest python2 command in configure
silverwind Feb 15, 2017
6d03af4
test: refactor test-dgram-membership
Trott Feb 14, 2017
eaad395
test: improve message in net-connect-local-error
Trott Feb 15, 2017
f6ddf8f
doc: dns examples implied string args were arrays
sam-github Feb 13, 2017
488cb02
assert: remove unneeded condition
Trott Feb 11, 2017
e652927
assert: unlock the assert API
Trott Feb 10, 2017
dbcae5a
test: improve crypto coverage
akito0107 Feb 10, 2017
39a184c
doc: update code examples in domain.md
vsemozhetbyt Feb 1, 2017
280bae4
src: remove unused typedef
bnoordhuis Feb 12, 2017
ee93460
test: add coverage for dgram _createSocketHandle()
cjihrig Feb 10, 2017
afa1219
test: improve punycode test coverage
seppevs Feb 3, 2017
0d180e0
doc: update email and add personal pronoun
JungMinu Feb 12, 2017
3a30105
meta: adding Italo A. Casas PGP Fingerprint
Feb 6, 2017
16b7bf2
test: add vm module edge cases
fhinkel Feb 9, 2017
886a7a5
meta: remove Chris Dickinson from CTC
chrisdickinson Feb 9, 2017
5f041d1
doc: drop "and io.js" from release section
bnoordhuis Jan 28, 2017
51702ef
doc: improve consistency in documentation titles
vsemozhetbyt Feb 7, 2017
cd2b3ab
doc: clarify the behavior of Buffer.byteLength
seishun Feb 9, 2017
25be1df
tools: add compile_commands.json gyp generator
bnoordhuis Aug 5, 2016
1c87bfb
doc: add and fix System Error properties
darai0512 Jan 24, 2017
25eaeb6
doc: fix typo in dgram doc
Trott Feb 5, 2017
b47b8f5
build: disable C4267 conversion compiler warning
bnoordhuis Feb 6, 2017
888ca4a
test: increase specificity in dgram test
Trott Feb 5, 2017
7e3bd8e
doc: remove extraneous paragraph from assert doc
Trott Feb 5, 2017
660137e
doc: improve testing guide
joyeecheung Feb 3, 2017
a3e7461
doc: add not-an-aardvark as ESLint contact
Trott Feb 4, 2017
761b8dd
meta: add explicit deprecation and semver-major policy
jasnell Aug 3, 2016
d6b8e75
doc: typographical fixes in COLLABORATOR_GUIDE.md
addaleax Feb 4, 2017
c47c764
doc: fix "initial delay" link in http.md
Krinkle Feb 1, 2017
8394093
doc: remove assertions about assert
Trott Feb 2, 2017
6f81f99
doc: edit stability text for clarity and style
Trott Feb 2, 2017
e18a138
doc: clarify msg when doc/api/cli.md not updated
Jan 18, 2017
f12fd17
doc: add personal pronouns option
Trott Jan 31, 2017
8a76705
src: unconsume stream fix in internal http impl
Kasher Jan 26, 2017
92e2767
readline: update 6 comparions to strict
umairishaq Jan 31, 2017
d9607c2
crypto: Remove expired certs from CNNIC whitelist
shigeki Nov 4, 2016
f87a422
crypto: add cert check issued by StartCom/WoSign
shigeki Nov 4, 2016
039f3f4
test: improve coverage on removeListeners functions
Feb 3, 2017
39872c5
test: improve error messages in test-npm-install
gonenduk Jan 26, 2017
b1d9028
doc: fix confusing example in dns.md
vsemozhetbyt Jan 26, 2017
1e5b40c
doc: edit CONTRIBUTING.md for clarity
Trott Jan 27, 2017
88415b7
doc: correct and complete dgram's Socket.bind docs
strugee Jan 26, 2017
a228c34
doc: add who to CC list for dgram
cjihrig Jan 27, 2017
dfff9d1
doc: fix typo in http.md
magnetikonline Jan 24, 2017
22f7e23
test: add 2nd argument to throws in test-assert
Marlena Jan 29, 2017
d14d262
test: require handler to be run in sigwinch test
Trott Jan 30, 2017
a0f1b23
test: refactor test-fs-utimes
jun-oka Oct 26, 2016
05b048c
test: improve test-fs-readfile-zero-byte-liar
edsadr Jan 2, 2017
2941672
test: improve test-http-chunked-304
edsadr Jan 7, 2017
166ac14
test: refactor the code in test-child-process-spawn-loop.js
sivaprs Jan 4, 2017
743bdf9
test: refactor test-watch-file.js
sivaprs Jan 7, 2017
4a9a43c
test: refactor test-doctool-html.js
hiroppy Jan 8, 2017
0262497
test: refactor the code of test-keep-alive.js
sivaprs Jan 8, 2017
6361e35
src: enable writev for pipe handles on Unix
aqrln Jan 7, 2017
1866b68
benchmark: don't lint autogenerated modules
mscdex Jan 12, 2017
28e0762
test: use realpath for NODE_TEST_DIR in common.js
gibfahn Jan 10, 2017
4cca3f2
test: fix temp-dir option in tools/test.py
gibfahn Jan 10, 2017
9aeb34a
readline: refactor construct Interface
JacksonTian Jan 18, 2016
f68fb7c
test: improve tests in pummel/test-exec
chasestarr Jan 12, 2017
b74fb85
doc: remove duplicate properties bullet in readme
trendsetter37 Jan 11, 2017
4f6b8bf
test: improve the code in test-process-cpuUsage
edsadr Jan 12, 2017
fe316c4
build: move source files from headers section
danbev Jan 17, 2017
385e3fe
test: tests for _readableStream.awaitDrain
shmuga Jan 17, 2017
43bc890
test: add http-common's test
hiroppy Jan 16, 2017
8a21d2a
test: add message verification on assert.throws
tmeisenh Jan 19, 2017
f735344
crypto: freelist_max_len is gone in OpenSSL 1.1.0
agl Jan 17, 2017
de1faeb
src: add a missing space in node_os.cc
aqrln Jan 21, 2017
df8438a
test: check fd 0,1,2 are used, not access mode
jBarz Dec 16, 2016
6c11106
test: increase coverage for punycode's decode
hiroppy Jan 21, 2017
7c186da
test: improve test-assert
richnologies Jan 20, 2017
6c91914
buffer: improve toJSON() performance
mscdex Jan 19, 2017
abee209
test: don't connect to :: (use localhost instead)
gibfahn Jan 17, 2017
beb0943
test: test hmac binding robustness
sam-github Jan 20, 2017
ba0b838
tools: rename eslintrc to an undeprecated format
thefourtheye Jul 13, 2016
d04c7ff
test: refactor cluster-preload.js
hiroppy Jan 9, 2017
65b7200
test: improve code in test-http-host-headers
edsadr Jan 16, 2017
562f23f
test: improve test-stream2-large-read-stall
stefanjudis Jan 10, 2017
5294723
test: improve code in test-domain-multi
edsadr Jan 15, 2017
a7a8681
test: improve code in test-console-instance
edsadr Jan 17, 2017
eb74100
test: improving coverage for dgram
hiroppy Jan 13, 2017
535a424
test: add dgram.Socket.prototype.bind's test
hiroppy Jan 19, 2017
5e5a38d
test: improve code in test-crypto-verify
edsadr Jan 20, 2017
0277eea
crypto: return the retval of HMAC_Update
tmeisenh Jan 19, 2017
1e96c8d
test: add process.assert's test
hiroppy Jan 20, 2017
cfbbf64
tools,doc: add Google Analytics tracking.
phillipj Jan 25, 2017
f866bac
test: enhance test-timers
Trott Jan 23, 2017
c6fa7b6
benchmark: add benchmark for object properties
targos Jan 21, 2017
10e06d1
test: expand test coverage of fs.js
vinimdocarmo Jan 23, 2017
dc207cd
benchmark: add more thorough timers benchmarks
Fishrock123 Jan 20, 2017
5cb1b05
test: allow for slow hosts in spawnSync() test
Trott Jan 25, 2017
f69d94b
test: increase coverage for stream's duplex
hiroppy Jan 23, 2017
b5985f4
doc: remove Chris Dickinson from active releasers
bnoordhuis Jan 26, 2017
bbf2484
test: add known_issues test for #10223
AnnaMag Jan 26, 2017
67f9f85
test: increase setMulticastLoopback() coverage
cjihrig Feb 10, 2017
281999e
util: don't init Debug if it's not needed yet
bengl Sep 8, 2016
b8629f7
dgram: fix possibly deoptimizing use of arguments
vsemozhetbyt Feb 8, 2017
0fe9ac3
http: make request.abort() destroy the socket
lpinca Jan 15, 2017
ffde243
doc: handle backpressure when write() return false
mcollina Jan 5, 2017
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
doc: handle backpressure when write() return false
The doc specified that writable.write() was advisory only. However,
ignoring that value might lead to memory leaks. This PR specifies that
behavior. Moreover, it adds an example on how to listen for the 'drain'
event correctly.

See: f347dad
PR-URL: #10631
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
mcollina committed Mar 13, 2017
commit ffde243f979111848de476238765e2f2385a8a9e
46 changes: 42 additions & 4 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -727,11 +727,49 @@ The return value indicates if you should continue writing right now.
If the data had to be buffered internally, then it will return
`false`. Otherwise, it will return `true`.

This return value is strictly advisory. You MAY continue to write,
even if it returns `false`. However, writes will be buffered in
memory, so it is best not to do this excessively. Instead, wait for
the [`'drain'`][] event before writing more data.
The return value is `true` if the internal buffer does not exceed
`highWaterMark` configured when the stream was created after admitting `chunk`.
If `false` is returned, further attempts to write data to the stream should
stop until the [`'drain'`][] event is emitted.

While a stream is not draining, calls to `write()` will buffer `chunk`, and
return false. Once all currently buffered chunks are drained (accepted for
delivery by the operating system), the `'drain'` event will be emitted.
It is recommended that once write() returns false, no more chunks be written
until the `'drain'` event is emitted. While calling `write()` on a stream that
is not draining is allowed, Node.js will buffer all written chunks until
maximum memory usage occurs, at which point it will abort unconditionally.
Even before it aborts, high memory usage will cause poor garbage collector
performance and high RSS (which is not typically released back to the system,
even after the memory is no longer required). Since TCP sockets may never
drain if the remote peer does not read the data, writing a socket that is
not draining may lead to a remotely exploitable vulnerability.

Writing data while the stream is not draining is particularly
problematic for a [Transform][], because the `Transform` streams are paused
by default until they are piped or an `'data'` or `'readable'` event handler
is added.

If the data to be written can be generated or fetched on demand, it is
recommended to encapsulate the logic into a [Readable][] and use
[`stream.pipe()`][]. However, if calling `write()` is preferred, it is
possible to respect backpressure and avoid memory issues using the
the [`'drain'`][] event:

```js
function write (data, cb) {
if (!stream.write(data)) {
stream.once('drain', cb)
} else {
process.nextTick(cb)
}
}

// Wait for cb to be called before doing any other write.
write('hello', () => {
console.log('write completed, do more writes now')
})
```

## API for Stream Implementors

Expand Down