Philipp M
Philipp M

Reputation: 3498

Node Cluster module, which is incompatible with Passenger

I'm using node.js express passport and recently rate-limiter-flexible ... and I've noticed I getting this error message:

server.js

const { RateLimiterMemory, RateLimiterRes } = require('rate-limiter-flexible');

console error:

[ N 2019-12-19 17:30:36.7775 15266/Ta age/Cor/CoreMain.cpp:1358 ]: Checking whether to disconnect long-running connections for process 20096, application /var/www/host/project (production)
App 16152 output: Trace: You required the Node Cluster module, which is incompatible with Passenger, a non-functional shim was returned and your app may still work. However, please remove the related code as soon as possible.
App 16152 output:     at Module.require (/usr/share/passenger/helper-scripts/node-loader.js:63:12)
App 16152 output:     at require (internal/modules/cjs/helpers.js:16:16)
App 16152 output:     at Object.<anonymous> (/var/www/host/project/node_modules/rate-limiter-flexible/lib/RateLimiterCluster.js:22:17)
App 16152 output:     at Module._compile (internal/modules/cjs/loader.js:774:30)
App 16152 output:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
App 16152 output:     at Module.load (internal/modules/cjs/loader.js:641:32)
App 16152 output:     at Function.Module._load (internal/modules/cjs/loader.js:556:12)
App 16152 output:     at Module.require (internal/modules/cjs/loader.js:681:19)
App 16152 output:     at Module.require (/usr/share/passenger/helper-scripts/node-loader.js:80:25)
App 16152 output:     at require (internal/modules/cjs/helpers.js:16:16)

What is this and how can I solve it?

Upvotes: 0

Views: 1162

Answers (2)

Nico Serrano
Nico Serrano

Reputation: 797

I ran into the same error message after trying to deploy my NodeJS app (which uses the cluster module) into a shared hosting that has cPanel and the "Setup Node.js App" option.

The incompatibility issue is explained in the Passenger documentation which I recommend you to read: Fundamental Concepts Phusion Passenger

Specifically this part where it explains why cluster module is incompatible with Passenger:

Passenger replaces the Cluster module. No boilerplate code is required: Passenger can launch your app in multiple processes and load balance traffic automatically, with no code changes most of the time, aside from the removal of the cluster module boilerplate if you've already added it. Besides this, the biggest advantage that Passenger provides is that it can load balance WebSockets, Socket.IO and SockJS through the use of sticky sessions. These technologies do not work well with the Cluster module because the Cluster module's load balancing mechanism is generic (and thus cannot implement sticky sessions), while Passenger's mechanism is specifically written for HTTP. If you are using Passenger, and we hope you do, then you must not include the Cluster module in your project as it conflicts with Passenger

Upvotes: 0

Animir
Animir

Reputation: 1204

I think, it is related to index.js, where all classes are imported including RateLimiterCluster. If you don't use it, you can try to require exact class you need by full path

const RateLimiterRedis = require('rate-limiter-flexible/lib/RateLimiterRedis');

Upvotes: 3

Related Questions