Skip to content

Commit 6f1cd29

Browse files
committed
--wip-- [skip ci]
1 parent ea3b89d commit 6f1cd29

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

packages/client/lib/client/commands-queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SinglyLinkedList, DoublyLinkedNode, DoublyLinkedList, EmptyAwareSinglyLinkedList } from './linked-list';
1+
import { DoublyLinkedNode, DoublyLinkedList, EmptyAwareSinglyLinkedList } from './linked-list';
22
import encodeCommand from '../RESP/encoder';
33
import { Decoder, PUSH_TYPE_MAPPING, RESP_TYPES } from '../RESP/decoder';
44
import { TypeMapping, ReplyUnion, RespVersions, RedisArgument } from '../RESP/types';

packages/client/lib/client/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ export default class RedisClient<
492492
console.log(`Moving to ${host}:${port} before ${afterMs}ms`);
493493

494494
// 2
495-
this.#paused = true;
495+
console.log(`Pausing writing until new socket is ready and all in-flight commands are completed`);
496+
// this.#paused = true;
496497

497498
const oldSocket = this.#socket;
498499
this.#socket = this.#initiateSocket({
@@ -512,17 +513,21 @@ export default class RedisClient<
512513
// 4
513514
if(!this.#queue.isWaitingForReply()) {
514515
// 5 and 6
516+
console.log(`All in-flight commands completed`);
517+
console.log(`Resume writing`)
515518
oldSocket.destroy();
516519
this.#paused = false;
517520
}
518521
});
519522

520523
// 4
521524
this.#queue.events.once('waitingForReplyEmpty', () => {
522-
525+
console.log(`All in-flight commands completed`);
523526
// 3
524527
if(this.#socket.isReady) {
525528
// 5 and 6
529+
console.log(`Connected to ${host}:${port}`);
530+
console.log(`Resume writing`)
526531
oldSocket.destroy();
527532
this.#paused = false;
528533
}
@@ -793,7 +798,6 @@ export default class RedisClient<
793798

794799
return new RedisSocket(socketInitiator, options?.socket)
795800
.on('data', chunk => {
796-
console.log('Data received', chunk.toString());
797801
try {
798802
this.#queue.decoder.write(chunk);
799803
} catch (err) {
@@ -802,7 +806,6 @@ export default class RedisClient<
802806
}
803807
})
804808
.on('error', err => {
805-
console.error('Socket error', err);
806809
this.emit('error', err);
807810
this.#clientSideCache?.onError();
808811
if (this.#socket.isOpen && !this.#options?.disableOfflineQueue) {

packages/client/lib/client/linked-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class EmptyAwareSinglyLinkedList<T> extends SinglyLinkedList<T> {
218218
}
219219
return ret;
220220
}
221-
remove(node: SinglyLinkedNode<T>, parent: SinglyLinkedNode<T> | undefined): T | undefined {
221+
remove(node: SinglyLinkedNode<T>, parent: SinglyLinkedNode<T> | undefined) {
222222
const old = this.length;
223223
super.remove(node, parent);
224224
if(old !== this.length && this.length === 0) {

packages/client/lib/client/socket.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export default class RedisSocket extends EventEmitter {
219219
try {
220220
await this.#initiator();
221221
} catch (err) {
222+
console.log('Initiator failed', err);
222223
this.#socket.destroy();
223224
this.#socket = undefined;
224225
throw err;

0 commit comments

Comments
 (0)