Skip to content

Conversation

@lpinca
Copy link
Member

If false is not returned a readable stream piped into the socket
might continue reading indefinitely until the process goes out of
memory.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

If `false` is not returned a readable stream piped into the socket might continue reading indefinitely until the process goes out of memory.
@lpinca
Copy link
MemberAuthor

'use strict';constnet=require('net');const{ Readable }=require('stream');constchunk=Buffer.alloc(1024);constreadable=newReadable({read(){this.push(chunk);}});constserver=net.createServer(function(socket){server.close();socket.resume();setTimeout(function(){socket.end();},100);});server.listen(function(){constsocket=net.connect(this.address().port,function(){socket.resume();socket.on('error',function(){});readable.pipe(socket);});});

@Trott
Copy link
Member

Trott commented Jun 1, 2019

Does the documentation for socket.write() need an update to reflect this?

Returns true if the entire data was flushed successfully to the kernel
buffer. Returns false if all or part of the data was queued in user memory.
['drain'][] will be emitted when the buffer is again free.

@lpinca
Copy link
MemberAuthor

lpinca commented Jun 2, 2019

@Trott I think it's not needed. writeAfterFIN() replaces writeAfterEnd() to give the user a better error message.

When writeAfterEnd() is used writable.write() return false. An error is emitted to signal that the write has not been successful.

@addaleaxaddaleax added the net Issues and PRs related to the net subsystem. label Jun 2, 2019
@TrottTrott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 3, 2019
@nodejs-github-bot
Copy link
Collaborator

@danbev
Copy link
Contributor

Landed in 714a32c.

@danbevdanbev closed this Jun 4, 2019
danbev pushed a commit that referenced this pull request Jun 4, 2019
If `false` is not returned a readable stream piped into the socket might continue reading indefinitely until the process goes out of memory. PR-URL: #27996 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
@lpincalpinca deleted the return/false branch June 8, 2019 11:46
BridgeAR pushed a commit that referenced this pull request Jun 17, 2019
If `false` is not returned a readable stream piped into the socket might continue reading indefinitely until the process goes out of memory. PR-URL: #27996 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
@BridgeARBridgeAR mentioned this pull request Jun 17, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.netIssues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@lpinca@Trott@nodejs-github-bot@danbev@addaleax@cjihrig