socket.io
socket.io copied to clipboard
Bug in socket.io-adapter: broadcast() calls encoder.encode with no callback
Bug in socket.io-adapter: Adapter.broadcast() calls Encoder.encode with no callback
Adapter.broadcast() is calling this.encoder.encode without passing a callback function.
This causes a runtime exception, like this:
UnhandledPromiseRejectionWarning: TypeError: callback is not a function
at Encoder.encode (.........\node_modules\socket.io-parser\index.js:135:5)
at ClusterAdapter.broadcast (.........\node_modules\@socket.io\cluster-adapter\node_modules\socket.io-adapter\dist\index.js:107:45)
at ClusterAdapter.onMessage (.........\node_modules\@socket.io\cluster-adapter\dist\index.js:90:23)
at process.emit (events.js:323:22)
Source code
from node_modules\@socket.io\cluster-adapter\node_modules\socket.io-adapter\dist\index.js
const flags = opts.flags || {};
const basePacketOpts = {
preEncoded: true,
volatile: flags.volatile,
compress: flags.compress
};
packet.nsp = this.nsp.name;
const encodedPackets = this.encoder.encode(packet);
Hi! Looks like a version incompatibilty. Which version of @socket.io/cluster-adapter and socket.io are you using?
In effect I was using socket.io 2.x. Switching to 4.1 solved the problem.