Skip to content

Commit

Permalink
revert: feat: expose current offset to allow deduplication
Browse files Browse the repository at this point in the history
This reverts commit 4e64123.

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.
  • Loading branch information
darrachequesne committed Feb 6, 2023
1 parent 8aa9499 commit 3734b74
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
17 changes: 0 additions & 17 deletions lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}).
Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 0 additions & 24 deletions test/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
// });
});

0 comments on commit 3734b74

Please sign in to comment.