Skip to content

Timed out event is still buffered #4318

Open
@shayanYousefi

Description

@shayanYousefi

Describe the bug

For a timed out event, If connection between client and server is disrupted but not closed yet, client still buffers event.

To Reproduce

1- After connection between client and server is established disconnect the network.
2- before the client closes the connection send an event with timeout.
3- after the event times out connect the network.
4- client still sends the timed out event

Socket.IO server version: 4.4.1

Server

import { Server } from "socket.io";

const port = 3000;
const io = new Server(port);
console.log(`listening to ${port}`);

io.on("connection", (socket) => {
	console.log('user connected');
	socket.on("emited", (cb) => {
        console.log('got event');
		cb('done');
	});
});
});

Socket.IO client version: 4.4.1

Client

import { io } from "socket.io-client";

const socket = io("ws://server-ip:3000");

// send a message to the server
setTimeout(() => {
	socket.timeout(1000).emit("emited", (err, msg) => {
		if (err) {
			console.log(err);
			return;
		}
		console.log(msg);
	});
	console.log('event sent');
}, 10000);

Expected behavior

After the event times out, the event should have been removed from buffer so it wouldn't be sent to server.

Platform:

  • OS:Ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions