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

294 Commits

Author SHA1 Message Date
d8e14fa4fe fix(scan): remove console.logs (#3038)
fixes #3037
2025-07-28 14:54:50 +03:00
d941ec5a4c Add Redis 8.2 New Stream Commands (#3029)
* chore: update Redis version from 8.2-RC1-pre to 8.2-rc1

* feat: implement XDELEX command for Redis 8.2

* feat: implement XACKDEL command for Redis 8.2

* refactor: create shared stream deletion types
  for Redis 8.2 commands

* feat: add Redis 8.2 deletion policies to XTRIM
  command

* feat: add Redis 8.2 deletion policies to XADD commands

* fix: correct XDELEX command method name and test parameter
2025-07-25 17:58:28 +03:00
ff8319d2d7 fix(pool): chain promise handlers to prevent unhandled rejections (#3035) 2025-07-25 16:39:32 +03:00
1c266371a3 Release client@5.6.1 2025-07-23 15:52:42 +00:00
4ae14bb558 Add Redis transparent proxy test utilities (#3019) 2025-07-23 18:21:13 +03:00
0541b32f34 docs: Update doctests (#3020)
* move all doctests from emb-examples branch

* fix readme

* add package-lock.json

* --wip-- [skip ci]

* fix: replace client.quit() with client.close() as quit is deprecated

- doctests/cmds-hash.js
- doctests/cmds-list.js
- doctests/cmds-servermgmt.js
- doctests/cmds-set.js

* fix: replace client.quit() with client.close() as quit is deprecated

- doctests/cmds-sorted-set.js
- doctests/cmds-string.js
- doctests/dt-bitfield.js
- doctests/dt-bitmap.js

* fix: replace client.quit() with client.close() as quit is deprecated

- dt-bloom.js: replace client.quit() with client.close()
- dt-cms.js: replace client.quit() with client.close()
- dt-cuckoo.js: replace client.quit() with client.close() and update expected output comments to reflect v5 boolean returns
- dt-geo.js: replace client.quit() with client.close()

* fix(doctests): correct pfAdd return values and replace quit with close

- Fix dt-hll.js: pfAdd returns 1 instead of true in comments and assertions
- Fix dt-hash.js and dt-hll.js: replace deprecated client.quit() with client.close()

* fix(doctests): correct API usage and return values in json and list examples

- Fix dt-json.js: use options object for json.type, json.strLen, json.del, json.arrPop, json.objLen, json.objKeys
- Fix dt-json.js: correct json.del return value from [1] to 1
- Fix dt-list.js: correct client initialization, return values (null, OK, 1), and error type
- Replace deprecated client.quit() with client.close() in both files

* fix(doctests): update dt-set.js and dt-ss.js for v5 compliance

- Updated boolean return values to numbers for SISMEMBER and SMISMEMBER commands
- Fixed client lifecycle to use client.close() instead of client.quit()
- Removed unnecessary await from createClient()
- Added order-independent assertions for set operations
- Removed debug statement

* fix(doctests): update deprecated methods and imports for v5 compliance

- Fix dt-string.js: remove await from client creation and replace client.quit() with client.close()
- Fix dt-tdigest.js: replace deprecated client.quit() with client.close()
- Fix dt-topk.js: replace client.quit() with client.close() and fix output comment from [1, 0] to [true, false]
- Fix query-agg.js: update @redis/search imports to use new constant names and replace client.disconnect() with client.close()

* fix(doctests): update imports and replace deprecated disconnect with close

- Replace SchemaFieldTypes/VectorAlgorithms with SCHEMA_FIELD_TYPE/SCHEMA_VECTOR_FIELD_ALGORITHM
- Replace client.disconnect() with client.close() for consistent deprecation handling
- Update query-combined.js, query-em.js, query-ft.js, and query-geo.js

* fix(doctests): update imports and replace deprecated methods in remaining files

- Update imports to use SCHEMA_FIELD_TYPE and SCHEMA_VECTOR_FIELD_ALGORITHM constants
- Replace deprecated disconnect() and quit() methods with close()
- Fix assertion in search-quickstart.js to use correct bicycle ID

* fix(doctests): update cmds-generic.js and cmds-cnxmgmt.js for v5 compliance

- Replace deprecated client.quit() with client.close()
- Update sScanIterator to use collection-yielding behavior (value -> values)
- Fix HSCAN API changes: tuples renamed to entries
- Fix cursor type issues: use string '0' instead of number 0 for hScan
- Fix infinite loop in scan cleanup by using do-while pattern

* fix(doctests): update dt-streams.js object shapes and parameters for v5 compliance

- Update stream result objects from tuple format to proper object format with id/message properties
- Change xRead/xReadGroup results from nested arrays to objects with name/messages structure
- Update xAutoClaim results to use nextId, messages, and deletedMessages properties
- Add missing properties to xInfo* results (max-deleted-entry-id, entries-added, recorded-first-entry-id, entries-read, lag, inactive)
- Modernize parameter names (count -> COUNT, block -> BLOCK, etc.)
- Update MAXLEN/APPROXIMATE options to new TRIM object structure
- Fix error message format for XADD duplicate ID error
- Update boolean return values (True -> OK)

---------

Co-authored-by: Nikolay Karadzhov <nkaradzhov89@gmail.com>
2025-07-23 18:16:08 +03:00
539fe52236 fix(client): make socket.host not required (#3024)
Underlying node tls.ConnectionOptions does not require host,
so we shouldnt as well. Further, if `url` is provided in
the upper level config, it takes precedence, which could be misleading:

createClient({
  url: 'rediss://user:secret@localhost:6379/0',
  socket: {
    tls: true,
    host: 'somehost' <-- this gets overwritten to `localhost`
  }
});

fixes #3023
2025-07-21 18:17:07 +03:00
748cad2e7f Release client@5.6.0 2025-07-08 11:37:25 +00: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
742d5713e8 fix(commands): sPopCount return Array<string> (#3006)
Also, touch the tests for spop and spopcount
to use the new parseCommand API

fixes #3004
2025-06-25 13:15:44 +03:00
c5b4f47975 feat: add support for vector sets (#2998)
* wip

* improve the vadd api

* resp3 tests

* fix some tests

* extract json helper functions in client package

* use transformJsonReply

* remove the CACHEABLE flag for all vector set commands

currently, client side caching is not supported
for vector set commands by the server

* properly transform vinfo result

* add resp3 test for vlinks

* add more tests for vrandmember

* fix vrem return types

* fix vsetattr return type

* fix vsim_withscores

* implement vlinks_withscores

* set minimum docker image version to 8

* align return types

* add RAW variant for VEMB -> VEMB_RAW

* use the new parseCommand api
2025-06-24 13:35:29 +03:00
b52177752e feat: added support for new bitop operations (#3001)
refactored bitop tests, covered all operations

updated default docker version on all packages
2025-06-19 13:56:00 +03:00
5d205cf161 chore(tests): bump test container version 8.0.2 (#2997) 2025-06-16 10:20:49 +03:00
62ac8b7c32 fix(client): make unstable cmds throw (#2990)
As per the docs, unstableResp3 commands should throw
when client is created with { RESP: 3, unstableResp3: false|undefined }

fixes #2989
2025-06-06 15:38:52 +03:00
0ebe55cbd7 Release client@5.5.6 2025-06-06 10:02:58 +03:00
b33a662e50 Automate release (#2977)
* release-it/bumper

* remove git:false

* fix package ordering

* adjust git add

* fix git config

* adjust git config for all packages

* add noop release script for test-utils

* no need to try to release root

* better way to handle skipping

* pass parameters down

* better version hint

* update node version

* return git arguments from before

* rename release workflow

* rename workflow

* set git.tagMatch

* add link to docs

* update description

* update workspace order in package-lock

* fix secondary releases

release-it/bumper was removing the ^ before the peerDep to client
npm is not happy with that. one potential fix would be to bump all
packages together as a prestep and then proceed without bupming again.
for now, this fix should bring us to the previous state ( what was used
in the manual process )

* require clean working dir in root

* remove root release-it config

not needed
2025-06-04 10:52:14 +03:00
20c16e0c2c (docs) add jsdoc comments to command parsers (#2984)
* (docs) bloom: add jsdocs for all commands

* (docs) json: add jsdocs

* (docs) search: add jsdocs for all commands

* (docs) jsdocs for std commands

* (docs) jsdoc comments to time series commands
2025-06-03 14:38:07 +03:00
4b939a7bdb Release client@5.1.1 2025-05-28 16:16:25 +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
27537b0ab7 fix(cluster): replace native private with _ (#2971)
Private class fields (e.g., #execute) cause runtime errors when accessed from contexts where `this` is not the exact instance, triggering “Receiver must be an instance of class RedisCluster”.

fixes #2967
2025-05-22 10:35:16 +03:00
9ea260f0f9 fix(handshake): ignore errors on client.setinfo (#2969)
As per the documentation (https://redis.io/docs/latest/commands/client-setinfo):

Client libraries are expected to pipeline this command after authentication on all connections and ignore failures since they could be connected to an older version that doesn't support them.

Turns out different versions of redis server return different errors, so its better to catch all.

fixes #2968
2025-05-21 11:38:29 +03:00
00845570ac Release client@5.1.0 2025-05-20 15:53:24 +03:00
4a5f879ec9 fix(client): bring disableClientInfo option back (#2959)
* fix(client): bring disableClientInfo option back

It disappeared in v5

fixes #2958
2025-05-20 15:15:09 +03:00
f3d1d3352e feat(client): expose socketTimeout option (#2965)
The maximum duration (in milliseconds) that the socket can remain idle (i.e., with no data sent or received) before being automatically closed. Default reconnectionStrategy will ignore the new SocketTimeoutError, but users are allowed to have custom strategies wich handle those errors in different ways
2025-05-20 14:28:15 +03:00
d0a5c4c945 Fix sentinel csc tests (#2966)
Co-authored-by: H. Temelski <hristo.temelski@redis.com>
2025-05-20 11:04:11 +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
6f961bd715 fix(client): cache subsequent clients (#2963)
* fix(client): cache subsequent clients

we dont need to recreate a client if
its config hasnt changed

fixes #2954

* handle circular structures

* make cache generic
2025-05-14 17:23:22 +03:00
bb7845dfe3 Disable readOnly for cluster s/pubsub client (#2950) 2025-05-08 10:29:05 +03:00
86480aaa74 fix cluster.sUnsubscribe - make listener optional (#2946) 2025-05-07 16:11:09 +03:00
7b737821b2 fix: fix various command import issues (#2944)
* fix: fix various command import issues

there was some sort of a circular dependency
in <module>/lib/commands/index.ts for various modules

fixes #2937 fixes #2941

* remove redundant definition
2025-05-07 16:10:35 +03:00
bc4b2101ee Export CommandParser from client index file and fix doc (#2945)
* Export CommandParser from client index file

* Tidy up long export line in client index file

Wrap and sort entries.

* Adapt and fix wrong examples in programmability doc
2025-05-07 16:10:03 +03:00
87b77e3e5f fix(client): add type annotations (#2949)
Fix type parameter for transformTuplesReply in CONFIG_GET and HGETALL commands

fixes #2933
2025-05-07 13:47:23 +03:00
404db30837 Release client@5.0.1 2025-05-05 11:51:15 +03:00
bf2b3752d6 Release client@5.0.0 2025-04-30 16:56:53 +03:00
46bfeaa94e Fix typo and improve Sentinel docs (#2931) 2025-04-30 16:30:16 +03:00
9459660d96 fix(pubsub): Fixed cluster client pubsub logic
* Infer the cluster pubsub client read only mode from the node type

* Modify flag logic
2025-04-30 15:57:01 +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
048df302e4 Fix imports (#2929)
* fix: exports

align exports with v4 as much as possible

* document breaking changes

* export type

return SetOptions export
2025-04-30 14:38:32 +03:00
bf06a3b703 Release client@5.0.0-next.7 2025-03-25 10:19:53 +02:00
4cbecf6a09 feat(hash field expiration): Added hash field expiration commands (#2907)
* [CAE-686] Added hash field expiration commands

* [CAE-686] Improve HSETEX return type

* [CAE-686] Minor pushTuples change, renamed HSETEX test

* [CAE-686] Changed hsetex function signature for better consistency with other commands

* [CAE-686] Fixed hsetex test

* [CAE-686] Bumped docker version to 8.0-M05-pre, enabled and fixed tests
2025-03-19 12:26:23 +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
6066692cb9 Release client@5.0.0-next.6 2025-01-30 11:02:54 +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
ffa7d2525c Fix cluster-slots discover race condition again (#2867) 2024-11-25 15:36:33 -05:00
9a3e1c5e03 Fix creation of cluster client again (#2870)
* shallow copy of this.#options.defaults.socket

* shallow copy of this.#options.defaults.socket

* nit

* fix redis create cluster client again

---------

Co-authored-by: Max Gruenfelder <maximilian.gruenfelder@sap.com>
Co-authored-by: Leibale Eidelman <me@leibale.com>
2024-11-25 15:28:44 -05:00
8dab27ed02 fix sentinel generics (#2859)
* fix sentinel generics

* comment nit
2024-11-04 10:23:34 -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
dca39e1402 Release client@5.0.0-next.5 2024-10-15 17:30:06 +02:00