1
0
mirror of https://github.com/redis/node-redis.git synced 2025-07-31 05:44:24 +03:00

53 Commits

Author SHA1 Message Date
4ae14bb558 Add Redis transparent proxy test utilities (#3019) 2025-07-23 18:21:13 +03:00
65a12d50e7 feat(client): add command timeout option (#3008)
Co-authored-by: Florian Schunk <149071178+florian-schunk@users.noreply.github.com>
2025-07-07 11:37:08 +03:00
79749f2461 fix(sentinel): propagate RESP option to clients (#3011)
`createSentinel` takes RESP as an option, but does not propagate down
to the actual clients. This creates confusion for the users as they
expect the option to be set to all clients, which is reasonable.

In case of clientSideCaching, this problem manifests as validation failure
because clientSideCaching requires RESP3, but if we dont propagate,
clients start with the default RESP2

fixes #3010
2025-07-07 11:06:34 +03:00
f346bad64e Adapt legacy sentinel tests to use the new test utils (#2976)
* modified legacy sentinel tests

* Adapt legacy sentinel tests to use the new test utils

* modify tmpdir creation

* reduced sentinel config timeouts, removed unneeded comment

---------

Co-authored-by: H. Temelski <hristo.temelski@redis.com>
2025-05-27 14:21:22 +03:00
f01f1014cb Client Side Caching (#2947)
* CSC POC ontop of Parser

* add csc file that weren't merged after patch

* address review comments

* nits to try and fix github

* last change from review

* Update client-side cache and improve documentation

* Add client side caching RESP3 validation

* Add documentation for RESP and unstableResp3 options

* Add comprehensive cache statistics

The `CacheStats` class provides detailed metrics like hit/miss counts,
load success/failure counts, total load time, and eviction counts.
It also offers derived metrics such as hit/miss rates, load failure rate,
and average load penalty. The design is inspired by Caffeine.

`BasicClientSideCache` now uses a `StatsCounter` to accumulate these
statistics, exposed via a new `stats()` method. The previous
`cacheHits()` and `cacheMisses()` methods have been removed.

A `recordStats` option (default: true) in `ClientSideCacheConfig`
allows disabling statistics collection.

---------

Co-authored-by: Shaya Potter <shaya@redislabs.com>
2025-05-19 15:11:47 +03:00
10ff6debab fix(sentinel): Migrated to the new testing framework, fixed issues that were discovered during transition
* [CAE-342] Fix a couple of bugs

* Fixed issue with nodes masterauth persistency, changed docker container

* [CAE-342] Fixed a couple of sentinel issues, enabled most tests

* [CAE-342] Added comment

* [CAE-342] Migrate majority of tests to testUtils

* [CAE-342] Minor refactor

* .

* [CAE-342] Using cae containers for sentinel

* [CAE-342] Improved resiliency of the legacy tests, added TSdoc comment

* [CAE-342] Some extra logging, removed unneeded changes

* [CAE-342] Moved docker env as optional part of redisserverdockerconfig

* [CAE-342] Move password to serverArguments

* [CAE-342] Moved ts-node to devDependencies

* [CAE-342] Reverted legacy testing framework improvements
2025-04-30 15:56:29 +03:00
924dafabc3 refactor(test-utils): remove TODO comments and TypeScript ignore directives for socket port (#2915) 2025-03-26 15:17:35 +02:00
a7feb60e0a tests: bumped the version of the 8 docker test image to '8.0-M05-pre' (#2909) 2025-03-18 15:24:11 +02:00
69d507a572 refactor!: redis 8 compatibility improvements and test infrastructure updates (#2893)
* churn(test): use redislabs/client-libs-test for testing

This  switches our testing infrastructure from redis/redis-stack to
redislabs/client-libs-test Docker image across all packages. This change
also updates the default Docker version from 7.4.0-v1 to 8.0-M04-pre.

* churn(test): verify CONFIG SET / GET compatibility with Redis 8

- Add tests for Redis 8 search configuration settings
- Deprecate Redis Search CONFIG commands in favor of standard CONFIG
- Test read-only config restrictions for Redis 8

* churn(test): handle Redis 8 coordinate precision in GEOPOS

- Update GEOPOS tests to handle increased precision in Redis 8 (17 decimal places vs 14)
- Add precision-aware coordinate comparison helper
- Add comprehensive test suite for coordinate comparison function

* test(search): adapt SUGGET tests for Redis 8 empty results

- Update tests to expect empty array ([]) instead of null for SUGGET variants
- Affects sugGet, sugGetWithPayloads, sugGetWithScores, and sugGetWithScoresWithPayloads

* test(search): support Redis 8 INFO indexes_all field

- Add indexes_all field introduced in Redis 8 to index definition test

* refactor!(search): simplify PROFILE commands to return raw response

- BREAKING CHANGE: FT.PROFILE now returns raw response, letting users implement their own parsing

* test: improve version-specific test coverage

- Add `testWithClientIfVersionWithinRange` method to run tests for specific Redis versions
- Refactor TestUtils to handle version comparisons more accurately
- Update test utilities across Redis modules to run tests against multiple versions, and not against latest only
2025-02-27 10:56:58 +02:00
6d21de3f31 feat(auth): add Entra ID identity provider integration for Redis client authentication (#2877)
* feat(auth): refactor authentication mechanism to use CredentialsProvider

- Introduce new credential providers: AsyncCredentialsProvider, StreamingCredentialsProvider
- Update client handshake process to use the new CredentialsProviders and to support async credentials fetch / credentials refresh
- Internal conversion of username/password to a CredentialsProvider
- Modify URL parsing to accommodate the new authentication structure
- Tests

* feat(auth): auth extensions

Introduces TokenManager and supporting classes to handle token acquisition, automatic
refresh, and updates via identity providers. This foundation enables consistent
authentication token management across different identity provider implementations.

Key additions:
- Add TokenManager to obtain and maintain auth tokens from identity providers
  with automated refresh scheduling based on TTL and configurable thresholds
- Add IdentityProvider interface for token acquisition from auth providers
- Implement Token class for managing token state and TTL tracking
- Include configurable retry mechanism with exponential backoff and jitter
- Add comprehensive test suite covering refresh cycles and error handling

This change establishes the core infrastructure needed for reliable token
lifecycle management across different authentication providers.

* feat(auth): add Entra ID identity provider integration

Introduces Entra ID (former Azure AD) authentication support with multiple authentication flows
and automated token lifecycle management.

Key additions:
- Add EntraIdCredentialsProvider for handling Entra ID authentication flows
- Implement MSALIdentityProvider to integrate with MSAL/EntraID authentication library
- Add support for multiple authentication methods:
  - Managed identities (system and user-assigned)
  - Client credentials with certificate
  - Client credentials with secret
  - Authorization Code flow with PKCE
- Add factory class with builder methods for each authentication flow
- Include sample Express server implementation for Authorization Code flow
- Add comprehensive configuration options for authority and token management

* feat(test-utils): improve cluster testing

- Add support for configuring replica authentication with 'masterauth'
- Allow default client configuration during test cluster creation

This improves the testing framework's flexibility by automatically
configuring replica authentication when '--requirepass' is used and
enabling custom client configurations across cluster nodes.

* feat(auth): add EntraId integration tests

- Add integration tests for token renewal and re-authentication flows
- Update credentials provider to use uniqueId as username instead of account username
- Add test utilities for loading Redis endpoint configurations
- Split TypeScript configs into separate files for samples and integration tests
- Remove `@redis/authx` package and nest it under `@`
2025-01-30 10:29:19 +02:00
b835309cf8 fix cross packages imports 2024-11-04 12:21:17 -05:00
4708736f3b new "transform arguments" API for better key and metadata extraction (#2733)
* Parser support with all commands

* remove "dist" from all imports for consistency

* address most of my review comments

* small tweak to multi type mapping handling

* tweak multi commands / fix addScript cases

* nits

* addressed all in person review comments

* revert addCommand/addScript changes to multi-commands

addCommand needs to be there for sendCommand like ability within a multi.

If its there, it might as well be used by createCommand() et al, to avoid repeating code.

addScript is there (even though only used once), but now made private to keep the logic for bookkeeping near each other.
2024-10-31 12:16:59 -04:00
b2d35c5286 V5 bringing RESP3, Sentinel and TypeMapping to node-redis
RESP3 Support
   - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion.
 
Sentinel

TypeMapping

Correctly types Multi commands

Note: some API changes to be further documented in v4-to-v5.md
2024-10-15 17:46:52 +03:00
4976231f24 upgrade deps, remove node 14 & 16 from tests matrix 2023-09-18 17:23:01 -04:00
fe74e322dd upgrade deps 2023-08-23 14:53:26 -04:00
0298c1ac41 upgrade deps (#2517)
* upgrade deps

* fix graph tests
2023-05-29 09:01:34 -04:00
4937efca6b upgrade dependencies (#2426) 2023-02-24 18:05:43 -05:00
0a46fcbdaf upgrade dependencies (#2381)
* upgrade deps

* upgrade dependencies

* fix v3 benchmark

* update package-lock.json
2023-01-25 13:05:42 -05:00
3b1bad2296 Add support for sharded PubSub (#2373)
* refactor pubsub, add support for sharded pub sub

* run tests in redis 7 only, fix PUBSUB SHARDCHANNELS test

* add some comments and fix some bugs

* PubSubType, not PubSubTypes 🤦‍♂️

* remove test.txt

* fix some bugs, add tests

* add some tests

* fix #2345 - allow PING in PubSub mode (remove client side validation)

* remove .only

* revert changes in cluster/index.ts

* fix tests minimum version

* handle server sunsubscribe

* add 'sharded-channel-moved' event to docs, improve the events section in the main README (fix #2302)

* exit "resubscribe" if pubsub not active

* Update commands-queue.ts

* Release client@1.5.0-rc.0

* WIP

* use `node:util` instead of `node:util/types` (to support node 14)

* run PubSub resharding test with Redis 7+

* fix inconsistency in live resharding test

* add some tests

* fix iterateAllNodes when starting from a replica

* fix iterateAllNodes random

* fix slotNodesIterator

* fix slotNodesIterator

* clear pubSubNode when node in use

* wait for all nodes cluster state to be ok before testing

* `cluster.minimizeConections` tests

* `client.reconnectStrategry = false | 0` tests

* sharded pubsub + cluster 🎉

* add minimum version to sharded pubsub tests

* add cluster sharded pubsub live reshard test, use stable dockers for tests, make sure to close pubsub clients when a node disconnects from the cluster

* fix "ssubscribe & sunsubscribe" test

* lock search docker to 2.4.9

* change numberOfMasters default to 2

* use edge for bloom

* add tests

* add back getMasters and getSlotMaster as deprecated functions

* add some tests

* fix reconnect strategy + docs

* sharded pubsub docs

* Update pub-sub.md

* some jsdoc, docs, cluster topology test

* clean pub-sub docs

Co-authored-by: Simon Prickett <simon@redislabs.com>

* reconnect startegy docs and bug fix

Co-authored-by: Simon Prickett <simon@redislabs.com>

* refine jsdoc and some docs

Co-authored-by: Simon Prickett <simon@redislabs.com>

* I'm stupid

* fix cluster topology test

* fix cluster topology test

* Update README.md

* Update clustering.md

* Update pub-sub.md

Co-authored-by: Simon Prickett <simon@redislabs.com>
2023-01-25 11:00:39 -05:00
be90e62360 Add support for T-Digest (#2214)
* wip

* close #2216 - add support for TDIGEST.MERGESTORE and make compression optional on TDIGEST.CREATE

* fix some tdigest commands, use bloom edge docker

* fix index.ts

* 2.4-RC2 (v2.4.1)

* fix some commands and tests

* clean code
2022-11-01 15:45:47 -04:00
1c6d74ffcb fix #2189 - add graph --compact support (#2305)
* fix #2189 - add graph --compact support

* clean code

* fix graph string param escaping

* fix "is not assignable to parameter of type 'GraphClientType'"

* fix README
2022-11-01 15:45:35 -04:00
0abd950f03 fix tsbuild (#2307)
* fix tsbuild

* fix tsbuild

* fix tsbuild
2022-10-26 15:32:19 -04:00
29f734f60e upgrade dependencies (#2306) 2022-10-26 14:47:10 -04:00
35be671332 upgrade dependencies (#2242) 2022-08-22 18:23:43 -04:00
71d582368a Add support for client.unref() and client.ref() (#2188)
* close #2185 - add support for client.unref() and client.ref()

* allow sync tests
2022-07-13 07:01:20 -04:00
9ffc30c727 upgrade deps 2022-07-05 11:42:43 -04:00
6a850d36ae upgrade deps, fix "invalid save argument" error (#2174) 2022-06-30 13:07:29 -04:00
0752f143a6 prepare 4.1.0 (#2111)
* increase test coverage

* @node-redis to @redis

* ugprade deps

* fix benchmark

* use 7.0 docker (not rc), update readmes, clean code, fix @-redis import

* update readme

* fix function in cluster

* update docs

Co-authored-by: Chayim <chayim@users.noreply.github.com>

* Update clustering.md

* add subpackages move warning

* drop support for node 12

* upgrade deps

* fix tsconfig.base.json

Co-authored-by: Chayim <chayim@users.noreply.github.com>
2022-05-02 11:48:12 -04:00
432a7e3ebb upgrade deps (#2098) 2022-04-25 16:42:20 -04:00
11c6c24881 Add support for redis functions (#2020)
* fix #1906 - implement BITFIELD_RO

* initial support for redis functions

* fix test utils

* redis functions commands and tests

* upgrade deps

* fix "Property 'uninstall' does not exist on type 'SinonFakeTimers'"

* upgrade dockers version

* Merge branch 'master' of github.com:redis/node-redis into functions

* fix FUNCTION LIST WITHCODE and FUNCTION STATS

* upgrade deps

* set minimum version for FCALL and FCALL_RO

* fix FUNCTION LOAD

* FUNCTION LOAD

* fix FUNCTION LOAD & FUNCTION LIST & FUNCTION LOAD WITHCODE

* fix FUNCTION_LIST_WITHCODE test
2022-04-25 09:09:23 -04:00
79ee8f2029 upgrade dependencies (#2081) 2022-04-18 12:29:01 -04:00
33a3f3f6c6 run tests with redis 7 as well - copied from #2020 (#2062)
* run tests on redis 7 as well - copied from #2020

* copy some changes from #2020

* clean BITCOUNT
2022-03-30 08:12:21 -04:00
5ade5dadc0 upgrade dependencies (#2057)
* upgrade dependencies

* fix "Property 'uninstall' does not exist on type 'SinonFakeTimers'."
2022-03-27 16:27:05 -04:00
3547b20293 Graph (#1887)
* init

* implement graph commands

* add graph to packages table

* fix ts.infoDebug

* fix redisearch tests

* Update INFO_DEBUG.ts

* fix INFO.spec.ts

* test QUERY and SLOWLOG

Co-authored-by: Avital-Fine <avital.fine@redis.com>
2022-01-31 12:52:19 -05:00
84aebcca0f upgrade dependencies 2022-01-24 13:14:20 -05:00
a2299509a0 upgrade dependencies (#1863) 2022-01-20 16:23:31 -05:00
075ae3a9c0 upgrade dependencies 2022-01-13 07:10:17 -05:00
29ff6c8a36 update dependencies 2021-12-30 14:13:38 -05:00
b97d18b610 fix some types 2021-12-23 17:17:19 -05:00
a0de7967f9 buffers, buffers everywhere... 2021-12-20 14:47:51 -05:00
7565ae349d fix generated documentation 2021-12-13 14:21:02 -05:00
f55de0efbf improve encodeCommand performance, add set-get-delete-string benchmark 2021-12-01 20:17:52 -05:00
ae06af64fa npm update 2021-11-24 21:50:29 -05:00
b80bbc3eba npm update 2021-11-24 21:11:27 -05:00
22edf8a631 remove echo from docker entrypoint.sh 2021-11-24 21:05:58 -05:00
0cabe71cf8 replace @redis with @node-redis 2021-11-16 02:35:24 -05:00
93e7c908af npm update, remove html from readme 2021-11-15 17:11:39 -05:00
7d2629f083 Support esModuleInterop set to false. (#1717)
* Support esModuleInterop set to false.

When testing the upcoming 4.x release, we got a bunch of typescript
errors emitted from this project.

We quickly realized this is because the library uses the esModuleInterop
flag. This makes some imports _slightly_ easier to write, but it comes
at a cost: it forces any application or library using this library to
*also* have esModuleInterop on.

The `esModuleInterop` flag is a bit of a holdover from an earlier time,
and I would not recommend using it in libraries. The main issue is that
if it's set to true, you are forcing any users of the library to also
have `esModuleInterop`, where if you keep have it set to `false` (the
default), you leave the decision to the user.

This change should have no rammifications to users with
`esModuleInterop` on, but it will enable support for those that have it
off.

This is especially good for library authors such as myself, because I
would also like to keep this flag off to not force *my* users into this
feature.

* All tests now pass!

* Move @types/redis-parser into client sub-package

and removed a comma
2021-11-15 16:52:48 -05:00
38426fe2a4 move "all-in-one" to root folder 2021-11-09 19:55:16 -05:00
57539e7c3f fix test-utils 2021-11-09 19:32:31 -05:00