FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

net: make writeAfterFIN() return false by lpinca · Pull Request #27996 · nodejs/node · GitHub

/ node Public

net: make writeAfterFIN() return false - #27996

Closed
lpinca wants to merge 1 commit into
nodejs:masterfrom
lpinca:return/false
Closed

net: make writeAfterFIN() return false#27996
lpinca wants to merge 1 commit into
nodejs:masterfrom
lpinca:return/false

Conversation

lpinca commented May 31, 2019

Copy link
Copy Markdown
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 commented May 31, 2019

Copy link
Copy Markdown
Member Author
'use strict';

const net = require('net');
const { Readable } = require('stream');

const chunk = Buffer.alloc(1024);

const readable = new Readable({
  read() {
    this.push(chunk);
  }
});

const server = net.createServer(function(socket) {
  server.close();
  socket.resume();
  setTimeout(function() {
    socket.end();
  }, 100);
});

server.listen(function() {
  const socket = net.connect(this.address().port, function() {
    socket.resume();
    socket.on('error', function() {});

    readable.pipe(socket);
  });
});

Trott commented Jun 1, 2019

Copy link
Copy Markdown
Member

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 commented Jun 2, 2019
edited
Loading

Copy link
Copy Markdown
Member Author

@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.

addaleax added the net Issues and PRs related to the net subsystem. label Jun 2, 2019
Trott added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Jun 3, 2019

Copy link
Copy Markdown
Collaborator

danbev commented Jun 4, 2019

Copy link
Copy Markdown
Contributor

Landed in 714a32c.

danbev 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 <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
lpinca 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 <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
BridgeAR mentioned this pull request Jun 17, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. net Issues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL