cheminfo / cheminfo/pm2-bridge

Doesn't work for multiple receivers

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Hello. I need to do ipc from a sender to multiple receiver processes. pm2-bridge works fine when there is one sender and one receiver but outputs following error for any more receivers

```
pv1m-24 { data: 'ping', from: 'pv1' }
pv1m-24 { data: 'ping', from: 'pv1' }
pv1-25 { data: 'some data' }
pv1-26 Error: timeout exceeded
pv1-26 at Timeout._onTimeout (/Users/Infernus/ProjectsNode/probe/node_modules/pm2-bridge/src/index.js:76:24)
pv1-26 at tryOnTimeout (timers.js:228:11)
pv1-26 at Timer.listOnTimeout (timers.js:202:5)
```

Here's the code I'm using. Same script is being used for master and other processes. I'm telling them apart by using command line args in ecosystem.json.

```
if (!isMaster) {
// This block will run once by each receiver process.
pm2Bridge.send({
to: 'pv1m', // send something to the process with the pm2 name 'receiver'
data: 'ping' // Send some data along
}).then(function(message) {
// Receive the receiver's reply
console.log(message.data); // pong
}, function(err) {
// Something went wrong :(
// for example the receiver was not found
console.error(err);
});
} else {
// This block will run once for each receiver process and would reply to their message.
pm2Bridge.onMessage(function(message, context) {
console.log(message); // {from: 'sender', data: 'ping'}
context.reply({data: "some data"}); // Reply to the sender
});
}
```

Thanks

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the shown pm2 setup with one sender and multiple receiver processes, then inspect src/index.js around the timeout at line 76. Trace how messages and replies are matched when several receivers are active. Done means multiple receivers can send to the sender and receive replies without a timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.