Description
I'm testing keep alives in my WS application. I've just tried setting them to be sent all the time every 100ms, just for testing, and node.js core dumps when ping() is called.
The relevant code looks like this:
setInterval(() => {
wsServer.clients.forEach((client) => {
if (client.readyState !== Ws.OPEN) return;
client.ping();
});
}, options.webSocketKeepAlive);
If I comment out the ping() line, everything works fine. There might be another underlying cause elsewhere, but it's definitely the ping that triggers this. The server and client are both running on localhost in the same node.js process (as part of my test suite) and they're both using ws.
This is triggered immediately, so it's possible that I'm pinging during connection setup, after teardown or some other edge case. Regardless though, this shouldn't happen.
It's difficult to isolate this further down to a minimal reproduction, but if I do manage to do so I'll share that here.
ws version
Tested on both 8.2.2 & 7.55
Node.js Version
Tested on 14.17.0 and 16.8.0
System
System:
OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 676.45 MB / 15.40 GB
Container: Yes
Shell: 5.8 - /usr/bin/zsh
Expected result
client.ping() should either work, or raise a handleable error somewhere. It should never crash node.
Actual result
node[177127]: ../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: 0xb02d90 node::Abort() [node]
2: 0xb02e0e [node]
3: 0xbe4a7e int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) [node]
4: 0xbe5700 void node::StreamBase::JSMethod<&(int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&))>(v8::FunctionCallbackInfo<v8::Value> const&) [node]
5: 0xd471cb [node]
6: 0xd4844a [node]
7: 0xd48926 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
8: 0x15ce039 [node]
Aborted (core dumped)
(from v16.8.0)
Attachments
No response
Description
I'm testing keep alives in my WS application. I've just tried setting them to be sent all the time every 100ms, just for testing, and node.js core dumps when
ping()is called.The relevant code looks like this:
If I comment out the
ping()line, everything works fine. There might be another underlying cause elsewhere, but it's definitely the ping that triggers this. The server and client are both running on localhost in the same node.js process (as part of my test suite) and they're both using ws.This is triggered immediately, so it's possible that I'm pinging during connection setup, after teardown or some other edge case. Regardless though, this shouldn't happen.
It's difficult to isolate this further down to a minimal reproduction, but if I do manage to do so I'll share that here.
ws version
Tested on both 8.2.2 & 7.55
Node.js Version
Tested on 14.17.0 and 16.8.0
System
Expected result
client.ping()should either work, or raise a handleable error somewhere. It should never crash node.Actual result
(from v16.8.0)
Attachments
No response