Registry / messaging / mutual

mutual

JSON →
library0.4.20jsnpmunverified

Mutual is a Node.js library that provides Scala-inspired Actors using Redis as a message transport for distributed concurrency. Version 0.4.20 is currently in development, with a relatively stable interface but limited performance testing. It uses EventChannel and RemoteChannel abstractions to manage asynchronous processing chains and remote communication via Redis. Key differentiators include seamless swapping between local event channels and remote channels, event bubbling for error handling, and builder methods for serial/parallel control flow.

npm install mutual
INSTALL
IMPORT
SIG · MUTUAL
M
mutual
messagingjavascriptv0.4.20
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EventChannel
import { EventChannel } from 'mutual'
const EventChannel = require('mutual').EventChannel
ESM import is available; CommonJS destructuring also works as shown.
RedisTransport
import { RedisTransport } from 'mutual'
Use for setting up Redis connection; needs 'redis' package installed.
RemoteChannel
import { RemoteChannel } from 'mutual'
Required for cross-process or cross-machine channels.

Shows setup of a distributed chat server using RemoteChannel and RedisTransport, with EventChannel for error handling.

import { EventChannel, RemoteChannel, RedisTransport } from 'mutual'; import http from 'http'; const transport = new RedisTransport({ host: 'localhost', port: 6379 }); const channels = {}; const makeChannel = (name) => { const channel = new RemoteChannel({ name, transport }); channel.forward(events, name); channel.listen(); return channel; }; const getChannel = (name) => channels[name] ?? makeChannel(name); const events = new EventChannel(); events.on('error', (err) => console.error(err)); const app = http.createServer((req, res) => { const channelName = req.url?.split('/')[1]; if (!channelName) { res.statusCode = 404; res.end(); return; } if (req.method === 'GET') { getChannel(channelName).once('message', (msg) => res.end(msg)); } else if (req.method === 'POST') { let body = ''; req.on('data', chunk => body += chunk); req.on('end', () => { res.writeHead(202); res.end(); getChannel(channelName).emit('message', body); }); } }); app.listen(1337, () => console.log('Server running on port 1337'));
Debug
Known issues
breakingAPI may change as package is in development; interface is relatively stable but not guaranteed.
fix
Pin dependency version to 0.4.20 and monitor updates.
affects: 0.4.x
gotchaRemoteChannel requires Redis to be running; does not fall back to local mode automatically.
fix
Ensure Redis is installed and accessible; use EventChannel for local-only scenarios.
affects: >=0.0.0
deprecatedExample code uses require('mutual') but ESM imports are available.
fix
Use import syntax for modern Node.js projects.
affects: >=0.3.0
gotchaEventChannel 'error' event must be listened to; unhandled errors may crash process.
fix
Always attach an 'error' listener to EventChannel instances.
affects: >=0.0.0
breakingload and performance testing not done; may have scalability issues.
fix
Test under expected load before production use.
affects: 0.4.20
Errors
Common errors & fixes
Error: Redis connection refused
Redis server not running or incorrect host/port
fix
Start Redis server or check host/port in RedisTransport config.
TypeError: events.wrap is not a function
EventChannel instance used before method is available (version issue or wrong import)
fix
Ensure mutual version >= 0.2.0 and use 'new EventChannel()'.
ImportError: cannot import name 'EventChannel' from 'mutual'
Using old-style require or wrong import path in ESM
fix
Use proper import: import { EventChannel } from 'mutual';
Upgrade
Version history
0.4.20latest on npm
Audit
Dependencies
redisoptionalRequired for RemoteChannel to communicate over Redis
Agent activity
9 hits · last 30 days
node
6
OpenAI (training)
1
Resources
packagemutual
mutual — npm install mutual · libregistry