Are you an LLM? You can read better optimized documentation at /en/migration/redis-adapter-options.md for this page in Markdown format
Redis Adapter Options Are Validated
Applies to
@connectum/events-redis1.3.0.
Does this apply to you?
You need to act in three cases:
- You pass
brokerOptionswith amaxLenthat is not a positive safe integer, ablockMsthat is not a non-negative safe integer, or acountthat is not a positive safe integer.RedisAdapter()now throws aRangeErrorthat names the option and the value. Before,maxLen: 0made every publish trim the entry it had just written, so events vanished without an error, and an invalidblockMsorcountstarted and then failed every second in the consume loop so that nothing was delivered. - Your Redis server needs longer than
redisOptions.connectTimeout(10000 ms unless you set it) to become ready after the TCP connection, for example because of a slow TLS or AUTH handshake.connect()andsubscribe()now reject withRedisAdapter: connection not ready within N ms (redisOptions.connectTimeout). Before, they waited as long as the handshake took, and forever if it never finished. - You switch exhaustively over
RedisLifecycleEventwithout a default branch. The union has a new member,group-recreated.
If none of these applies, nothing changes.
Required changes
maxLen: 0. Remove the option to keep every entry, or set the stream length you want to retain.0never meant "no limit".- A
blockMsorcountthat is fractional,NaN, a string or negative. Pass a whole number.blockMs: 0is valid and blocks without a deadline (RedisBLOCK 0). - A slow handshake. Raise
redisOptions.connectTimeout, or set it to0to remove the deadline. - An exhaustive
switch. Add a branch forgroup-recreated, or a default branch.
typescript
// Before: accepted, and published events were trimmed away at once
RedisAdapter({ url, brokerOptions: { maxLen: 0 } });
// After: keep roughly the latest 100000 entries
RedisAdapter({ url, brokerOptions: { maxLen: 100_000 } });1
2
3
4
5
2
3
4
5
Behavior that changed without an option
When Redis loses a consumer group (restart without persistence, FLUSHALL, failover to a replica without the stream), the consumer now creates the group again and resumes. Before, it logged NOGROUP every second and delivered nothing until the service restarted. The new group starts at the beginning of the stream, so entries the old group had already handled can be delivered a second time. See Recovery after Redis loses a consumer group.
Verify the upgrade
Create the adapter in a startup test: an invalid option throws at that call. Point connect() at a port that accepts connections and stays silent and check that it rejects after connectTimeout.