Skip to content

Commit

Permalink
fix: set enableOfflineQueue off when the first redis connection is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
favoyang committed Oct 16, 2022
1 parent ad4d2a8 commit 2c9934c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ See more in https://github.com/luin/ioredis#connect-to-redis
> **Note**
> Since v0.2.5, verdaccio-redis-storage changed the redis library from node-redis to [ioredis](https://github.com/luin/ioredis).
### About the offline queue

By default, there is no active connection to the Redis server, commands are added to a queue and are executed once the connection is "ready". This is (only) necessary for the verdaccio-redis-storage initialziation, due to the way a verdaccio plugin is being invoked. You should not set the enableOfflineQueue boolean to false in the configuration file.

However, the offline queue feature will be disabled when the first redis connection is ready, to make following web requests fail instantly if a redis connection is down.

## Serving tarball

Redis is an in-memory database that is not good at dealing with large tarball files. It's highly recommended to use [verdaccio-storage-proxy](https://github.com/openupm/verdaccio-storage-proxy) to decouple the tarball accesses to another storage backend like [verdaccio-aws-s3-storage](https://github.com/verdaccio/monorepo/tree/master/plugins/aws-s3-storage) or [verdaccio-minio](https://github.com/barolab/verdaccio-minio).
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function redisCreateClient(config: string | RedisOptions, logger: Logger)

client.on("ready", function () {
logger.info("[verdaccio/redis] ready to use");
logger.info("[verdaccio/redis] set enableOfflineQueue to false to make following web requests fail instantly when redis connection is down");
client.options.enableOfflineQueue = false;
});

client.on('reconnecting', function (delay) {
Expand Down

0 comments on commit 2c9934c

Please sign in to comment.