* fix(ssubscribe): properly resubscribe in case of shard failover
1) when RE failover happens, there is a disconnect
2) affected Client reconnects and tries to resubscribe all existing listeners
ISSUE #1: CROSSSLOT Error - client was doing ssubscribe ch1 ch2.. chN which, after the failover could result in CROSSSLOT ( naturally, becasuse now some slots could be owned by other shards )
FIX: send one ssubscribe command per channel instead of one ssubscribe for all channels
ISSUE #2: MOVED Error - some/all of the channels might be moved somewhere else
FIX: 1: Propagate the error to the Cluster. 2: Cluster rediscovers topology.
3: Cluster resubscribes all listeners of the failed client ( possibly some/all of those will end up in a different client after the rediscovery )
fixes: #2902
Certain command parameter enums, specifically ClientKillFilters for the CLIENT KILL command, were not publicly exported by the @redis/client package. The purpose of this change is to make the ClientKillFilters enum accessible to all package consumers, eliminating the need for users to rely on an unstable internal import path.
This matters because it provides a reliable and supported way for developers to use commands that require these enums, improving the package's usability and API stability.
fixes: #2805
Co-authored-by: Nikolay Karadzhov <nkaradzhov89@gmail.com>
* rename maint options according to the latest client options
* adjust env variables
cae repo uses RE_FAULT_INJECTOR_URL for fault injector
DATABASE_NAME is needed to choose from the many databases in cae
* fix connection cleanup test
* feat(errors): Add specialized timeout error types for maintenance scenarios
- Added `SocketTimeoutDuringMaintananceError`, a subclass of `TimeoutError`, to handle socket timeouts during maintenance.
- Added `CommandTimeoutDuringMaintenanceError`, another subclass of `TimeoutError`, to address command write timeouts during maintenance.
* feat(linked-list): Add EmptyAwareSinglyLinkedList and enhance DoublyLinkedList functionality
- Introduced `EmptyAwareSinglyLinkedList`, a subclass of `SinglyLinkedList` that emits an `empty` event when the list becomes empty due to `reset`, `shift`, or `remove` operations.
- Added `nodes()` iterator method to `DoublyLinkedList` for iterating over nodes directly.
- Enhanced unit tests for `DoublyLinkedList` and `SinglyLinkedList` to cover edge cases and new functionality.
- Added comprehensive tests for `EmptyAwareSinglyLinkedList` to validate `empty` event emission under various scenarios.
- Improved code formatting and consistency.
* refactor(commands-queue): Improve push notification handling
- Replaced `setInvalidateCallback` with a more flexible `addPushHandler` method, allowing multiple handlers for push notifications.
- Introduced the `PushHandler` type to standardize push notification processing.
- Refactored `RedisCommandsQueue` to use a `#pushHandlers` array, enabling dynamic and modular handling of push notifications.
- Updated `RedisClient` to leverage the new handler mechanism for `invalidate` push notifications, simplifying and decoupling logic.
* feat(commands-queue): Add method to wait for in-flight commands to complete
- Introduced `waitForInflightCommandsToComplete` method to asynchronously wait for all in-flight commands to finish processing.
- Utilized the `empty` event from `#waitingForReply` to signal when all commands have been completed.
* feat(commands-queue): Introduce maintenance mode support for commands-queue
- Added `#maintenanceCommandTimeout` and `setMaintenanceCommandTimeout` method to dynamically adjust command timeouts during maintenance
* refator(client): Extract socket event listener setup into helper method
* refactor(socket): Add maintenance mode support and dynamic timeout handling
- Added `#maintenanceTimeout` and `setMaintenanceTimeout` method to dynamically adjust socket timeouts during maintenance.
* feat(client): Add Redis Enterprise maintenance configuration options
- Added `maintPushNotifications` option to control how the client handles Redis Enterprise maintenance push notifications (`disabled`, `enabled`, `au
to`).
- Added `maintMovingEndpointType` option to specify the endpoint type for reconnecting during a MOVING notification (`auto`, `internal-ip`, `external-ip`,
etc.).
- Added `maintRelaxedCommandTimeout` option to define a relaxed timeout for commands during maintenance.
- Added `maintRelaxedSocketTimeout` option to define a relaxed timeout for the socket during maintenance.
- Enforced RESP3 requirement for maintenance-related features (`maintPushNotifications`).
* feat(client): Add socket helpers and pause mechanism
- Introduced `#paused` flag with corresponding `_pause` and `_unpause` methods to
temporarily halt writing commands to the socket during maintenance windows.
- Updated `#write` method to respect the `#paused` flag, preventing new commands from being written during maintenance.
- Added `_ejectSocket` method to safely detach from and return the current socket
- Added `_insertSocket` method to receive and start using a new socket
* feat(client): Add Redis Enterprise maintenance handling capabilities
- Introduced `EnterpriseMaintenanceManager` to manage Redis Enterprise maintenance events and push notifications.
- Integrated `EnterpriseMaintenanceManager` into `RedisClient` to handle maintenance push notifications and manage socket transitions.
- Implemented graceful handling of MOVING, MIGRATING, and FAILOVER push notifications, including socket replacement and timeout adjustments.
* test: add E2E test infrastructure for Redis maintenance scenarios
* test: add E2E tests for Redis Enterprise maintenance timeout handling (#3)
* test: add connection handoff test
---------
Co-authored-by: Pavel Pashov <pavel.pashov@redis.com>
Co-authored-by: Pavel Pashov <60297174+PavelPashov@users.noreply.github.com>
RedisClusterType was using some type restrictions to
hide some commands based on its properties. In reality,
all commands should be exposed to user ( as in v4 ).
fixes#3064
It was very difficult to debug `ErrorReply` errors due to `error.stack` being erased.
Given this restores standard JS Error behaviour, I have not added any tests.
* feat(search): add SVS-VAMANA vector index algorithm support
- Add VAMANA algorithm with compression and tuning parameters
- Include comprehensive test coverage for various configurations
- Fix parameter validation to handle falsy values correctly
* feat(search): add additional VAMANA compression algorithms
- Add LVQ4, LVQ4x4, LVQ4x8, LeanVec4x8, and LeanVec8x8 compression options
- Update test to use LeanVec4x8 compression algorithm
* chore: update Redis version from 8.2-rc1 to 8.2-rc2-pre
* 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>
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
`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
* 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
* (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
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
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
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
* 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>
* 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