-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.
Description
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.
pimterry
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.