Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/Redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,16 @@
// Node ignores setKeepAlive before connect, therefore we wait for the event:
// https://github.com/nodejs/node/issues/31663
if (typeof options.keepAlive === "number") {

// prevents TypeScript error when used inside arrow function
const { keepAlive } = options;

if (stream.connecting) {
stream.once(CONNECT_EVENT, () => {
stream.setKeepAlive(true, options.keepAlive);
stream.setKeepAlive(true, keepAlive);
});
} else {
stream.setKeepAlive(true, options.keepAlive);
stream.setKeepAlive(true, keepAlive);
}
}

Expand Down Expand Up @@ -559,35 +563,35 @@
});
}

scanStream(options?: ScanStreamOptions) {

Check warning on line 566 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member scanStream should be declared before all private instance method definitions

Check warning on line 566 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member scanStream should be declared before all private instance method definitions

Check warning on line 566 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member scanStream should be declared before all private instance method definitions

Check warning on line 566 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member scanStream should be declared before all private instance method definitions

Check warning on line 566 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member scanStream should be declared before all private instance method definitions
return this.createScanStream("scan", { options });
}

scanBufferStream(options?: ScanStreamOptions) {

Check warning on line 570 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member scanBufferStream should be declared before all private instance method definitions

Check warning on line 570 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member scanBufferStream should be declared before all private instance method definitions

Check warning on line 570 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member scanBufferStream should be declared before all private instance method definitions

Check warning on line 570 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member scanBufferStream should be declared before all private instance method definitions

Check warning on line 570 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member scanBufferStream should be declared before all private instance method definitions
return this.createScanStream("scanBuffer", { options });
}

sscanStream(key: string, options?: ScanStreamOptions) {

Check warning on line 574 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member sscanStream should be declared before all private instance method definitions

Check warning on line 574 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member sscanStream should be declared before all private instance method definitions

Check warning on line 574 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member sscanStream should be declared before all private instance method definitions

Check warning on line 574 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member sscanStream should be declared before all private instance method definitions

Check warning on line 574 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member sscanStream should be declared before all private instance method definitions
return this.createScanStream("sscan", { key, options });
}

sscanBufferStream(key: string, options?: ScanStreamOptions) {

Check warning on line 578 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member sscanBufferStream should be declared before all private instance method definitions

Check warning on line 578 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member sscanBufferStream should be declared before all private instance method definitions

Check warning on line 578 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member sscanBufferStream should be declared before all private instance method definitions

Check warning on line 578 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member sscanBufferStream should be declared before all private instance method definitions

Check warning on line 578 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member sscanBufferStream should be declared before all private instance method definitions
return this.createScanStream("sscanBuffer", { key, options });
}

hscanStream(key: string, options?: ScanStreamOptions) {

Check warning on line 582 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member hscanStream should be declared before all private instance method definitions

Check warning on line 582 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member hscanStream should be declared before all private instance method definitions

Check warning on line 582 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member hscanStream should be declared before all private instance method definitions

Check warning on line 582 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member hscanStream should be declared before all private instance method definitions

Check warning on line 582 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member hscanStream should be declared before all private instance method definitions
return this.createScanStream("hscan", { key, options });
}

hscanBufferStream(key: string, options?: ScanStreamOptions) {

Check warning on line 586 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member hscanBufferStream should be declared before all private instance method definitions

Check warning on line 586 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member hscanBufferStream should be declared before all private instance method definitions

Check warning on line 586 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member hscanBufferStream should be declared before all private instance method definitions

Check warning on line 586 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member hscanBufferStream should be declared before all private instance method definitions

Check warning on line 586 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member hscanBufferStream should be declared before all private instance method definitions
return this.createScanStream("hscanBuffer", { key, options });
}

zscanStream(key: string, options?: ScanStreamOptions) {

Check warning on line 590 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member zscanStream should be declared before all private instance method definitions

Check warning on line 590 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member zscanStream should be declared before all private instance method definitions

Check warning on line 590 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member zscanStream should be declared before all private instance method definitions

Check warning on line 590 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member zscanStream should be declared before all private instance method definitions

Check warning on line 590 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member zscanStream should be declared before all private instance method definitions
return this.createScanStream("zscan", { key, options });
}

zscanBufferStream(key: string, options?: ScanStreamOptions) {

Check warning on line 594 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member zscanBufferStream should be declared before all private instance method definitions

Check warning on line 594 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member zscanBufferStream should be declared before all private instance method definitions

Check warning on line 594 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member zscanBufferStream should be declared before all private instance method definitions

Check warning on line 594 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member zscanBufferStream should be declared before all private instance method definitions

Check warning on line 594 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member zscanBufferStream should be declared before all private instance method definitions
return this.createScanStream("zscanBuffer", { key, options });
}

Expand All @@ -596,7 +600,7 @@
*
* @ignore
*/
silentEmit(eventName: string, arg?: unknown): boolean {

Check warning on line 603 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member silentEmit should be declared before all private instance method definitions

Check warning on line 603 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member silentEmit should be declared before all private instance method definitions

Check warning on line 603 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member silentEmit should be declared before all private instance method definitions

Check warning on line 603 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member silentEmit should be declared before all private instance method definitions

Check warning on line 603 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member silentEmit should be declared before all private instance method definitions
let error: unknown;
if (eventName === "error") {
error = arg;
Expand Down Expand Up @@ -631,7 +635,7 @@
/**
* @ignore
*/
recoverFromFatalError(

Check warning on line 638 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (20.x)

Member recoverFromFatalError should be declared before all private instance method definitions

Check warning on line 638 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (12.x)

Member recoverFromFatalError should be declared before all private instance method definitions

Check warning on line 638 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (14.x)

Member recoverFromFatalError should be declared before all private instance method definitions

Check warning on line 638 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (18.x)

Member recoverFromFatalError should be declared before all private instance method definitions

Check warning on line 638 in lib/Redis.ts

View workflow job for this annotation

GitHub Actions / test / test (16.x)

Member recoverFromFatalError should be declared before all private instance method definitions
_commandError: Error,
err: Error,
options: FlushQueueOptions
Expand Down
2 changes: 1 addition & 1 deletion lib/redis/RedisOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface CommonRedisOptions extends CommanderOptions {
* @link https://nodejs.org/api/net.html#socketsetkeepaliveenable-initialdelay
* @default 0
*/
keepAlive?: number;
keepAlive?: number | null;

/**
* Enable/disable the use of Nagle's algorithm.
Expand Down
3 changes: 3 additions & 0 deletions test/unit/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ describe("Redis", () => {

option = getOption("redis://localhost?family=6");
expect(option).to.have.property("family", 6);

option = getOption(1234, { keepAlive: null });
expect(option).to.have.property('keepAlive', null);
} catch (err) {
stub.restore();
throw err;
Expand Down