You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the example at https://github.com/animir/node-rate-limiter-flexible/wiki/PM2-cluster, we have one single-instance pm2 service for the RateLimiterClusterMasterPM2, and then we have another clustered service that uses new RateLimiterCluster() to initialize the rate-limiting, then we call .consume() in the client later.
If the order and timing of the service startup is as follows:
new RateLimiterClusterMasterPM2(pm2) happens in the master service,
new RateLimiterCluster() happens in the client services,
then all is good, and it works as expected.
However, if the order and timing of the service startup is as follows:
new RateLimiterCluster() happens in a client service,
thennew RateLimiterClusterMasterPM2(pm2) happens in the master service,
then later when we call .consume() in the client we get this error:
Error: RateLimiterCluster timeout: no answer from master in time
at Timeout._onTimeout (node_modules/rate-limiter-flexible/lib/RateLimiterCluster.js:188:14)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
Setting an arbitrarily large timeoutMs in the options passed to new RateLimiterCluster() such that the master should definitely have started within that many ms appears to make no difference.
This sequence of events also results in the same exception:
new RateLimiterClusterMasterPM2(pm2) happens in the master service,
new RateLimiterCluster() happens in the client services,
One or more .consume()s happen successfully,
The master service restarts while the client services continue to run uninterrupted,
then any further .consume() calls in the clients fail with RateLimiterCluster timeout: no answer from master in time
Is there something we should be doing differently, or is this something that can be fixed?
@ighunter Hi, thank you for the detailed description.
This looks like a bug.
Can you start the master process and only after it starts workers?
Can you restart workers, when master restarts?
I know this isn't the best solution, but you can try until we understand the problem.
Thanks @animir - yes, we have workarounds in place for now 👌
animir
changed the title
Error "RateLimiterCluster timeout: no answer from master in time" if the master is not already available when the client is created
PM2 cluster error "timeout: no answer from master in time" if the master is not already available when the client is created
Jan 3, 2024
Following the example at https://github.com/animir/node-rate-limiter-flexible/wiki/PM2-cluster, we have one single-instance pm2 service for the
RateLimiterClusterMasterPM2
, and then we have another clustered service that usesnew RateLimiterCluster()
to initialize the rate-limiting, then we call.consume()
in the client later.If the order and timing of the service startup is as follows:
new RateLimiterClusterMasterPM2(pm2)
happens in the master service,new RateLimiterCluster()
happens in the client services,then all is good, and it works as expected.
However, if the order and timing of the service startup is as follows:
new RateLimiterCluster()
happens in a client service,new RateLimiterClusterMasterPM2(pm2)
happens in the master service,then later when we call
.consume()
in the client we get this error:Setting an arbitrarily large
timeoutMs
in the options passed tonew RateLimiterCluster()
such that the master should definitely have started within that many ms appears to make no difference.This sequence of events also results in the same exception:
new RateLimiterClusterMasterPM2(pm2)
happens in the master service,new RateLimiterCluster()
happens in the client services,.consume()
s happen successfully,then any further
.consume()
calls in the clients fail withRateLimiterCluster timeout: no answer from master in time
Is there something we should be doing differently, or is this something that can be fixed?
Node version: 18.17.1
rate-limiter-flexible
version: 2.4.1OS: Ubuntu 22.04.3 LTS
The text was updated successfully, but these errors were encountered: