mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
fix: calling destroy() should clear all internal state
If a client was in the process of receiving some binary attachments
when the connection was abruptly closed, then the manager would call
`decoder.destroy()` ([1]) but was then stuck in a "parse error" loop
upon reconnection (since it expected a binary attachment and not a
CONNECT packet).
[1]: a1c528b089/lib/manager.ts (L520)
This commit is contained in:
@@ -69,27 +69,6 @@ describe("ArrayBuffer", () => {
|
||||
return helpers.test_bin(packet);
|
||||
});
|
||||
|
||||
it("cleans itself up on close", () => {
|
||||
const packet = {
|
||||
type: PacketType.EVENT,
|
||||
data: ["a", new ArrayBuffer(2), new ArrayBuffer(3)],
|
||||
id: 0,
|
||||
nsp: "/",
|
||||
};
|
||||
|
||||
const encodedPackets = encoder.encode(packet);
|
||||
|
||||
const decoder = new Decoder();
|
||||
decoder.on("decoded", (packet) => {
|
||||
throw new Error("received a packet when not all binary data was sent.");
|
||||
});
|
||||
|
||||
decoder.add(encodedPackets[0]); // add metadata
|
||||
decoder.add(encodedPackets[1]); // add first attachment
|
||||
decoder.destroy(); // destroy before all data added
|
||||
expect(decoder.reconstructor.buffers.length).to.be(0); // expect that buffer is clean
|
||||
});
|
||||
|
||||
it("should not modify the input packet", () => {
|
||||
const packet = {
|
||||
type: PacketType.EVENT,
|
||||
|
||||
Reference in New Issue
Block a user