Skip to content

4.5.0

Compare
Choose a tag to compare
@darrachequesne darrachequesne released this 24 Apr 20:18
· 61 commits to main since this release
abdba07

Features

  • add details to the disconnect event (b862924)

The "disconnect" event will now include additional details to help debugging if anything has gone wrong.

Example when a payload is over the maxHttpBufferSize value in HTTP long-polling mode:

socket.on("disconnect", (reason, details) => {
  console.log(reason); // "transport error"

  // in that case, details is an error object
  console.log(details.message); "xhr post error"
  console.log(details.description); // 413 (the HTTP status of the response)

  // details.context refers to the XMLHttpRequest object
  console.log(details.context.status); // 413
  console.log(details.context.responseText); // ""
});
  • add support for catch-all listeners for outgoing packets (74e3e60)

This is similar to onAny(), but for outgoing packets.

Syntax:

socket.onAnyOutgoing((event, ...args) => {
  console.log(event);
});
  • slice write buffer according to the maxPayload value (46fdc2f)

The server will now include a "maxPayload" field in the handshake details, allowing the clients to decide how many packets they have to send to stay under the maxHttpBufferSize value.

Links:

Size of the bundles:

min min+gzip
socket.io.min.js 42.6 KB (+ 2.2 KB ⬆️) 13.6 KB (+ 0.5 KB ⬆️)
socket.io.msgpack.min.js 47.7 KB (+ 2.1 KB ⬆️) 14.6 KB (+ 0.4 KB ⬆️)
socket.io.esm.min.js 34.5 KB (+ 1.4 KB ⬆️) 11.5 KB (+ 0.2 KB ⬆️)