From 3734b74b4595da76bcc5f9aa33381e9c405ff546 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Mon, 6 Feb 2023 17:36:37 +0100 Subject: [PATCH] revert: feat: expose current offset to allow deduplication This reverts commit 4e6412386267c237b0094373c8e9d2523058e69f. Using the id of the socket is not possible, since it is lost upon reconnection (unless connection recovery is successful), so we revert the previous change. --- lib/socket.ts | 17 ----------------- test/socket.ts | 24 ------------------------ 2 files changed, 41 deletions(-) diff --git a/lib/socket.ts b/lib/socket.ts index 97c264f559..b5a6e60894 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -217,22 +217,6 @@ export class Socket< * }); */ public connected: boolean = false; - /** - * The identifier of the current packet. Multiple retries of the same packet will have the same identifier, in order - * to allow deduplication (only process a packet once). - * - * @example - * io.on("connection", (socket) => { - * socket.on("my-event", async (payload, callback) => { - * const offset = socket.currentOffset; - * - * await insertInDatabase(payload, offset); - * - * callback(); - * }) - * }); - */ - public currentOffset: string; /** * The session ID, which must not be shared (unlike {@link id}). @@ -668,7 +652,6 @@ export class Socket< if (null != packet.id) { debug("attaching ack callback to event"); args.push(this.ack(packet.id)); - this.currentOffset = `${this.id}-${packet.id}`; } if (this._anyListeners && this._anyListeners.length) { diff --git a/test/socket.ts b/test/socket.ts index 4c7b784065..94613c53cf 100644 --- a/test/socket.ts +++ b/test/socket.ts @@ -1105,28 +1105,4 @@ describe("socket", () => { socket3.on("disconnect", partialDone); }); }); - - // TODO: enable once a new version of the socket.io-client package is released - // it("should retry with the same packet ID", (done) => { - // const io = new Server(0); - // let counter = 0; - // - // io.on("connection", (socket) => { - // socket.on("my-event", (cb) => { - // expect(socket.currentOffset).to.eql(socket.id + "-0"); - // if (++counter === 3) { - // cb(); - // - // success(done, io, clientSocket); - // } - // }); - // }); - // - // const clientSocket = createClient(io, "/", { - // retries: 10, - // ackTimeout: 20, - // }); - // - // clientSocket.emit("my-event"); - // }); });