Skip to content

Commit 3734b74

Browse files
revert: feat: expose current offset to allow deduplication
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.
1 parent 8aa9499 commit 3734b74

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

lib/socket.ts

-17
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,6 @@ export class Socket<
217217
* });
218218
*/
219219
public connected: boolean = false;
220-
/**
221-
* The identifier of the current packet. Multiple retries of the same packet will have the same identifier, in order
222-
* to allow deduplication (only process a packet once).
223-
*
224-
* @example
225-
* io.on("connection", (socket) => {
226-
* socket.on("my-event", async (payload, callback) => {
227-
* const offset = socket.currentOffset;
228-
*
229-
* await insertInDatabase(payload, offset);
230-
*
231-
* callback();
232-
* })
233-
* });
234-
*/
235-
public currentOffset: string;
236220

237221
/**
238222
* The session ID, which must not be shared (unlike {@link id}).
@@ -668,7 +652,6 @@ export class Socket<
668652
if (null != packet.id) {
669653
debug("attaching ack callback to event");
670654
args.push(this.ack(packet.id));
671-
this.currentOffset = `${this.id}-${packet.id}`;
672655
}
673656

674657
if (this._anyListeners && this._anyListeners.length) {

test/socket.ts

-24
Original file line numberDiff line numberDiff line change
@@ -1105,28 +1105,4 @@ describe("socket", () => {
11051105
socket3.on("disconnect", partialDone);
11061106
});
11071107
});
1108-
1109-
// TODO: enable once a new version of the socket.io-client package is released
1110-
// it("should retry with the same packet ID", (done) => {
1111-
// const io = new Server(0);
1112-
// let counter = 0;
1113-
//
1114-
// io.on("connection", (socket) => {
1115-
// socket.on("my-event", (cb) => {
1116-
// expect(socket.currentOffset).to.eql(socket.id + "-0");
1117-
// if (++counter === 3) {
1118-
// cb();
1119-
//
1120-
// success(done, io, clientSocket);
1121-
// }
1122-
// });
1123-
// });
1124-
//
1125-
// const clientSocket = createClient(io, "/", {
1126-
// retries: 10,
1127-
// ackTimeout: 20,
1128-
// });
1129-
//
1130-
// clientSocket.emit("my-event");
1131-
// });
11321108
});

0 commit comments

Comments
 (0)