socketio / socketio/socket.io

Timed out event is still buffered

Open
#4,318 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the client reproduction using socket.timeout(1000).emit() while the network is disconnected, then inspect the client timeout and buffering path. Done means that an event whose acknowledgement timeout has fired is not sent when the connection is restored; rerun the listed reproduction to verify this.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, typescript
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.