Skip to content

Commit 5bbd576

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents b1ee82c + 2f10632 commit 5bbd576

File tree

23 files changed

+326
-84
lines changed

23 files changed

+326
-84
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
node-version: ["18", "20", "22"]
25-
redis-version: ["rs-7.4.0-v1", "8.0.2", "8.2-rc1"]
25+
redis-version: ["rs-7.4.0-v1", "8.0.2", "8.2"]
2626
steps:
2727
- uses: actions/checkout@v4
2828
with:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Node Redis v5 adds support for [Client Side Caching](https://redis.io/docs/manua
241241
```typescript
242242
// Enable client side caching with RESP3
243243
const client = createClient({
244-
RESP: 3,
244+
RESP: 3,
245245
clientSideCache: {
246246
ttl: 0, // Time-to-live (0 = no expiration)
247247
maxEntries: 0, // Maximum entries (0 = unlimited)
@@ -304,6 +304,7 @@ Node Redis is supported with the following versions of Redis:
304304

305305
| Version | Supported |
306306
| ------- | ------------------ |
307+
| 8.2.z | :heavy_check_mark: |
307308
| 8.0.z | :heavy_check_mark: |
308309
| 7.4.z | :heavy_check_mark: |
309310
| 7.2.z | :heavy_check_mark: |

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bloom/lib/test-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import RedisBloomModules from '.';
44
export default TestUtils.createFromConfig({
55
dockerImageName: 'redislabs/client-libs-test',
66
dockerImageVersionArgument: 'redis-version',
7-
defaultDockerVersion: '8.2-rc1'
7+
defaultDockerVersion: '8.2'
88
});
99

1010
export const GLOBAL = {

packages/bloom/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@redis/bloom",
3-
"version": "5.7.0",
3+
"version": "5.8.0",
44
"license": "MIT",
55
"main": "./dist/lib/index.js",
66
"types": "./dist/lib/index.d.ts",
@@ -13,7 +13,7 @@
1313
"release": "release-it"
1414
},
1515
"peerDependencies": {
16-
"@redis/client": "^5.7.0"
16+
"@redis/client": "^5.8.0"
1717
},
1818
"devDependencies": {
1919
"@redis/test-utils": "*"

packages/client/lib/client/index.spec.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ describe('Client', () => {
6464
const expected: RedisClientOptions = {
6565
socket: {
6666
host: 'localhost',
67-
port: 6379
67+
port: 6379,
68+
tls: false
6869
},
6970
username: 'user',
7071
password: 'secret',
@@ -161,12 +162,58 @@ describe('Client', () => {
161162
{
162163
socket: {
163164
host: 'localhost',
165+
tls: false
164166
}
165167
}
166168
);
167169
});
168170
});
169171

172+
describe('parseOptions', () => {
173+
it('should throw error if tls socket option is set to true and the url protocol is "redis:"', () => {
174+
assert.throws(
175+
() => RedisClient.parseOptions({
176+
url: 'redis://localhost',
177+
socket: {
178+
tls: true
179+
}
180+
}),
181+
TypeError
182+
);
183+
});
184+
it('should throw error if tls socket option is set to false and the url protocol is "rediss:"', () => {
185+
assert.throws(
186+
() => RedisClient.parseOptions({
187+
url: 'rediss://localhost',
188+
socket: {
189+
tls: false
190+
}
191+
}),
192+
TypeError
193+
);
194+
});
195+
it('should not throw when tls socket option and url protocol matches"', () => {
196+
assert.equal(
197+
RedisClient.parseOptions({
198+
url: 'rediss://localhost',
199+
socket: {
200+
tls: true
201+
}
202+
}).socket.tls,
203+
true
204+
);
205+
assert.equal(
206+
RedisClient.parseOptions({
207+
url: 'redis://localhost',
208+
socket: {
209+
tls: false
210+
}
211+
}).socket.tls,
212+
false
213+
);
214+
});
215+
});
216+
170217
describe('authentication', () => {
171218
testUtils.testWithClient('Client should be authenticated', async client => {
172219
assert.equal(

packages/client/lib/client/index.ts

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,21 +315,45 @@ export default class RedisClient<
315315
return RedisClient.factory(options)(options);
316316
}
317317

318-
static parseURL(url: string): RedisClientOptions {
318+
static parseOptions<O extends RedisClientOptions>(options: O): O {
319+
if (options?.url) {
320+
const parsed = RedisClient.parseURL(options.url);
321+
if (options.socket) {
322+
if (options.socket.tls !== undefined && options.socket.tls !== parsed.socket.tls) {
323+
throw new TypeError(`tls socket option is set to ${options.socket.tls} which is mismatch with protocol or the URL ${options.url} passed`)
324+
}
325+
parsed.socket = Object.assign(options.socket, parsed.socket);
326+
}
327+
328+
Object.assign(options, parsed);
329+
}
330+
return options;
331+
}
332+
333+
static parseURL(url: string): RedisClientOptions & {
334+
socket: Exclude<RedisClientOptions['socket'], undefined> & {
335+
tls: boolean
336+
}
337+
} {
319338
// https://www.iana.org/assignments/uri-schemes/prov/redis
320339
const { hostname, port, protocol, username, password, pathname } = new URL(url),
321-
parsed: RedisClientOptions = {
340+
parsed: RedisClientOptions & {
341+
socket: Exclude<RedisClientOptions['socket'], undefined> & {
342+
tls: boolean
343+
}
344+
} = {
322345
socket: {
323-
host: hostname
346+
host: hostname,
347+
tls: false
324348
}
325349
};
326350

327-
if (protocol === 'rediss:') {
328-
parsed!.socket!.tls = true;
329-
} else if (protocol !== 'redis:') {
351+
if (protocol !== 'redis:' && protocol !== 'rediss:') {
330352
throw new TypeError('Invalid protocol');
331353
}
332354

355+
parsed.socket.tls = protocol === 'rediss:';
356+
333357
if (port) {
334358
(parsed.socket as TcpSocketConnectOpts).port = Number(port);
335359
}
@@ -464,15 +488,6 @@ export default class RedisClient<
464488
};
465489
}
466490

467-
if (options?.url) {
468-
const parsed = RedisClient.parseURL(options.url);
469-
if (options.socket) {
470-
parsed.socket = Object.assign(options.socket, parsed.socket);
471-
}
472-
473-
Object.assign(options, parsed);
474-
}
475-
476491
if (options?.database) {
477492
this._self.#selectedDB = options.database;
478493
}
@@ -481,6 +496,10 @@ export default class RedisClient<
481496
this._commandOptions = options.commandOptions;
482497
}
483498

499+
if (options) {
500+
return RedisClient.parseOptions(options);
501+
}
502+
484503
return options;
485504
}
486505

packages/client/lib/commands/EXPIRE.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { CommandParser } from '../client/parser';
22
import { RedisArgument, NumberReply, Command } from '../RESP/types';
33

44
export default {
5-
IS_READ_ONLY: true,
65
/**
76
* Sets a timeout on key. After the timeout has expired, the key will be automatically deleted
87
* @param parser - The Redis command parser

packages/client/lib/commands/EXPIREAT.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { RedisArgument, NumberReply, Command } from '../RESP/types';
33
import { transformEXAT } from './generic-transformers';
44

55
export default {
6-
IS_READ_ONLY: true,
76
/**
87
* Sets the expiration for a key at a specific Unix timestamp
98
* @param parser - The Redis command parser

0 commit comments

Comments
 (0)