Open
Description
Describe the bug
The file socket.io.esm.min.js
from the NPM package socket.io-client 4.8.0 contains a bug which breaks binary data when talking to other SocketIO implementations (for example python-socjetio).
Instead of {_placeholder: true, num: 0}
, the code produces {it: true, num: 0}
. It's correct in the source. The problem is somewhere in the ESM build.
To Reproduce
Search for function _deconstructPacket
in socket.io.js
. It looks like this:
function _deconstructPacket(data, buffers) {
if (!data) return data;
if (isBinary(data)) {
var placeholder = {
_placeholder: true,
num: buffers.length
};
In the ESM, it gets compiled into this code:
function ot(t, s) {
if (!t)
return t;
if (et(t)) {
const i = {
it: !0,
num: s.length
};
return s.push(t),
i
}
The same happens in _reconstructPacket
. Source:
function _reconstructPacket(data, buffers) {
if (!data) return data;
if (data && data._placeholder === true) {
var isIndexValid = typeof data.num === "number" && data.num >= 0 && data.num < buffers.length;
which is compiled into
function ct(t, s) {
if (!t)
return t;
if (t && !0 === t.it) {
if ("number" == typeof t.num && t.num >= 0 && t.num < s.length)
Expected behavior
The binary representation in the serialized message must be correct.
Platform:
- Device: any
- OS: any
Additional context
n.a.