Skip to content

Commit 8cda228

Browse files
committed
--wip-- [skip ci]
1 parent 21f46b9 commit 8cda228

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
@@ -516,7 +516,8 @@ export default class RedisClient<
516516
console.log(`Moving to ${host}:${port} before ${afterMs}ms`);
517517

518518
// 2
519-
this.#paused = true;
519+
console.log(`Pausing writing until new socket is ready and all in-flight commands are completed`);
520+
// this.#paused = true;
520521

521522
const oldSocket = this.#socket;
522523
this.#socket = this.#initiateSocket({
@@ -536,17 +537,21 @@ export default class RedisClient<
536537
// 4
537538
if(!this.#queue.isWaitingForReply()) {
538539
// 5 and 6
540+
console.log(`All in-flight commands completed`);
541+
console.log(`Resume writing`)
539542
oldSocket.destroy();
540543
this.#paused = false;
541544
}
542545
});
543546

544547
// 4
545548
this.#queue.events.once('waitingForReplyEmpty', () => {
546-
549+
console.log(`All in-flight commands completed`);
547550
// 3
548551
if(this.#socket.isReady) {
549552
// 5 and 6
553+
console.log(`Connected to ${host}:${port}`);
554+
console.log(`Resume writing`)
550555
oldSocket.destroy();
551556
this.#paused = false;
552557
}
@@ -812,7 +817,6 @@ export default class RedisClient<
812817

813818
return new RedisSocket(socketInitiator, options?.socket)
814819
.on('data', chunk => {
815-
console.log('Data received', chunk.toString());
816820
try {
817821
this.#queue.decoder.write(chunk);
818822
} catch (err) {
@@ -821,7 +825,6 @@ export default class RedisClient<
821825
}
822826
})
823827
.on('error', err => {
824-
console.error('Socket error', err);
825828
this.emit('error', err);
826829
this.#clientSideCache?.onError();
827830
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)