Closed koraniar closed 3 years ago
I am creating two Workers using cluster, the Main thread does not expose a port, just controls the Workers
cluster
I used the basic implementation of this library, I configure it in the app.js file in this way:
app.js
const redisUrl = app.get('redisUrl'); // redis://127.0.0.1:6379 app.configure(sync({ uri: redisUrl, })); if (cluster.isMaster) { app.removeAllListeners('sync-in'); }
In the Index.js file, I expose the port of the workers when the connection is ready in this way:
Index.js
app.sync.ready.then(() => { const port = app.get('port'); const server = app.listen(port); server.on('listening', () => logger.info(`WORKER #${cluster.worker.id} - Feathers application started on %s:%d`, app.get('host'), port)); });
Additionally, I put this log inside the channels.js in this way:
channels.js
app.service('executions').publish((data) => { console.log(`WORKER #${cluster.worker.id}`, data); });
When I update two registries (each register from a different client) using the patch method over a table called "executions" I get the following output:
patch
WORKER #2 - Feathers application started on localhost:3030 WORKER #1 - Feathers application started on localhost:3030 WORKER #1 { id: '84a6f208-8a23-41c2-beb2-73fe65056c19', deviceName: 'ESTEBANSVM-W10' } WORKER #2 { id: 'b5fd3369-42c7-4584-b472-767788fbef17', deviceName: 'Esteban’s MacBook Pro' } WORKER #1 { id: 'b5fd3369-42c7-4584-b472-767788fbef17', deviceName: 'Esteban’s MacBook Pro' }
Repeating the process (without restarting the server) I get this output:
serviceName WORKER #1 executions { id: 'f4ac27ef-2dde-4fa5-a8da-0c16f1346dca', deviceName: 'Esteban’s MacBook Pro' } serviceName WORKER #2 executions { id: 'eb859e30-1cad-4d1e-b395-769e2642da43', deviceName: 'ESTEBANSVM-W10' } serviceName WORKER #1 executions { id: 'eb859e30-1cad-4d1e-b395-769e2642da43', deviceName: 'ESTEBANSVM-W10' }
And repeating it again (without restarting the server) I get this output:
serviceName WORKER #1 executions { id: '9e124387-9086-40a8-90b6-3edc90355fbf', deviceName: 'Esteban’s MacBook Pro' } serviceName WORKER #2 executions { id: 'b8b710a5-42ac-4843-ae4e-c49da16bc021', deviceName: 'ESTEBANSVM-W10' }
The event should send to all the instances always.
Sometimes, the event is sent to all instances, sometimes the event is not sent to any instance, and sometimes the event is sent to some instances.
Module versions (especially the part that's not working):
NodeJS version: 10.19.0
Operating System: Mac OS 11.2.3 (Big Sur)
Browser Version: Chrome 90.0.4430.93
This module is intended to be used with Feathers v4 and later. Please upgrade to the current version and reopen if the problem persists.
Steps to reproduce
I am creating two Workers using
cluster
, the Main thread does not expose a port, just controls the WorkersI used the basic implementation of this library, I configure it in the
app.js
file in this way:In the
Index.js
file, I expose the port of the workers when the connection is ready in this way:Additionally, I put this log inside the
channels.js
in this way:When I update two registries (each register from a different client) using the
patch
method over a table called "executions" I get the following output:Repeating the process (without restarting the server) I get this output:
And repeating it again (without restarting the server) I get this output:
Expected behavior
The event should send to all the instances always.
Actual behavior
Sometimes, the event is sent to all instances, sometimes the event is not sent to any instance, and sometimes the event is sent to some instances.
System configuration
Module versions (especially the part that's not working):
NodeJS version: 10.19.0
Operating System: Mac OS 11.2.3 (Big Sur)
Browser Version: Chrome 90.0.4430.93