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

Setting the objectMode option in the net.Socket() constructor causes an abort on write #40336

Closed
lpinca opened this issue Oct 5, 2021 · 1 comment
Labels
confirmed-bug Issues with confirmed bugs. net Issues and PRs related to the net subsystem.

Comments

@lpinca
Copy link
Member

lpinca commented Oct 5, 2021

Version

v16.10.0

Platform

Darwin imac.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64

Subsystem

net

What steps will reproduce the bug?

$ cat crash.js
'use strict';

const net = require('net');

const server = net.createServer();

server.on('connection', function (socket) {
  socket.write(Buffer.from('foo'));
  socket.resume();
});

server.on('listening', function () {
  const { port } = server.address();
  const socket = net.createConnection({ port, objectMode: true });

  socket.on('data', function (chunk) {
    console.log(chunk);
    socket.write(chunk);
  });
});

server.listen();
$ node crash.js
<Buffer 66 6f 6f>
node[235]: ../src/stream_base.cc:220:int node::StreamBase::WriteString(const v8::FunctionCallbackInfo<v8::Value>&) [with node::encoding enc = (node::encoding)1]: Assertion `args[1]->IsString()' failed.
 1: 0xafd010 node::Abort() [node]
 2: 0xafd08e  [node]
 3: 0xbdfd0e int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 4: 0xbe0990 void node::StreamBase::JSMethod<&(int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&))>(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 5: 0xd4339b  [node]
 6: 0xd4462c  [node]
 7: 0xd44b06 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
 8: 0x15e8099  [node]
Aborted

How often does it reproduce? Is there a required condition?

Always. No required condition.

What is the expected behavior?

An error should be thrown if any of the objectMode, readableObjectMode, or writableObjectMode options are set when a net.Socket is instantiated.

What do you see instead?

The options are accepted but they not make sense in a socket context.

Additional information

The issue was found by @pimterry in websockets/ws#1952.

@lpinca lpinca added the net Issues and PRs related to the net subsystem. label Oct 5, 2021
@lpinca lpinca changed the title Setting the objectMode option the a net.Socket() constructor causes an abort on write Setting the objectMode option in the net.Socket() constructor causes an abort on write Oct 5, 2021
@juanarbol juanarbol added the confirmed-bug Issues with confirmed bugs. label Oct 5, 2021
@juanarbol
Copy link
Member

Not sure about this, I was considering reading the docs, but they seem to be outdated, the socket.connect(options[, connectListener]), or I do not know if this is misuse or we do not support that bjectMode option or our docs are outdated

watilde added a commit to watilde/node that referenced this issue Oct 6, 2021
watilde added a commit to watilde/node that referenced this issue Oct 6, 2021
watilde added a commit to watilde/node that referenced this issue Oct 7, 2021
watilde added a commit to watilde/node that referenced this issue Oct 7, 2021
watilde added a commit to watilde/node that referenced this issue Oct 7, 2021
nodejs-github-bot pushed a commit that referenced this issue Oct 13, 2021
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>

PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
nodejs-github-bot pushed a commit that referenced this issue Oct 13, 2021
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>

PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
nodejs-github-bot pushed a commit that referenced this issue Oct 13, 2021
PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
nodejs-github-bot pushed a commit that referenced this issue Oct 13, 2021
PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
targos pushed a commit that referenced this issue Oct 13, 2021
Fixes: #40336

PR-URL: #40344
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
targos pushed a commit that referenced this issue Oct 13, 2021
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>

PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
targos pushed a commit that referenced this issue Oct 13, 2021
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>

PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
targos pushed a commit that referenced this issue Oct 13, 2021
PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
targos pushed a commit that referenced this issue Oct 13, 2021
PR-URL: #40344
Fixes: #40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. net Issues and PRs related to the net subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants