Registry / messaging / prpcow

prpcow

JSON →
library2.0.0-alpha.23jsnpmunverified

Plain Remote Procedure Call over WebSocket for Node.js (>=18.18.2) and modern browsers. Current stable version: 2.0.0-alpha.23 (pre-release). Enables bidirectional RPC where both client and server can expose functions callable via await. Features custom modelResolvers and functionResolvers, and allows custom WebSocket implementations. Peer dependency on ws (^8.5.0 || ^7.5.0). Differentiators: symmetric call pattern, native async/await, no code generation. Pre-release with potential breaking changes.

npm install prpcow
INSTALL
IMPORT
SIG · PRPCOW
P
prpcow
messagingjavascriptv2.0.0-alpha.23
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.

PRPCOW
import { PRPCOW } from 'prpcow'
const PRPCOW = require('prpcow')
ESM-only; cannot use CommonJS require. PRPCOW is the core class.
PRPCOWClient
import { PRPCOWClient } from 'prpcow'
import PRPCOWClient from 'prpcow'
Named export, not default. PRPCOWClient is the client-side class.
ModelResolver
import { ModelResolver } from 'prpcow'
import { ModelResolver } from 'prpcow'
TypeScript type/interface for custom resolvers. Only import if using TypeScript or custom resolver.
FunctionResolver
import { FunctionResolver } from 'prpcow'
TypeScript type/interface for function resolvers.

Demonstrates basic server setup with PRPCOW and ws, registering a function, and making a bidirectional call from client.

import { PRPCOW } from 'prpcow'; import { WebSocketServer } from 'ws'; const wss = new WebSocketServer({ port: 8080 }); const rpc = new PRPCOW({ wss: wss }); rpc.register('greet', (name: string) => `Hello, ${name}!`); wss.on('connection', (ws) => { const client = rpc.connect(ws); client.call('add', { a: 2, b: 3 }).then(console.log).catch(console.error); }); // Client side: import { PRPCOWClient } from 'prpcow'; const ws = new WebSocket('ws://localhost:8080'); const client = new PRPCOWClient(ws); client.call('greet', { name: 'World' }).then(console.log); // Hello, World!
Debug
Known issues
breakingVersion 2.0.0-alpha.23 changes API: 'PRPCOW' class replaces older patterns. Constructor now expects options object with 'wss' instead of separate parameters.
fix
Update to new class-based API; see migration guide or tests.
affects: <2.0.0-alpha.23
breakingNode.js engine requirement increased to >=18.18.2 (from >=16.x in earlier versions). Older Node.js versions may fail to install.
fix
Upgrade Node.js to >=18.18.2 or use prpcow v1.x (if available).
affects: >=2.0.0
gotchaPeer dependency 'ws' must be manually installed for Node.js usage. Client-side in browsers uses native WebSocket, no peer dep needed.
fix
Run 'npm install ws' in backend project. For browser usage, ensure WebSocket API available.
affects: >=2.0.0
gotchaBoth server and client must call 'connect' or use PRPCOWClient appropriately. Failure to do so results in 'Connection not established' errors.
fix
Always call connect on server side with the WebSocket instance, or use PRPCOWClient on client side.
affects: >=2.0.0
deprecatedIntegration with ws v7.x is deprecated; ws v8.x is recommended for better performance and security.
fix
Update ws to v8.x in package.json.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prpcow'
Package not installed or misconfigured import path.
fix
Run 'npm install prpcow' and use correct import syntax (ESM).
TypeError: prpcow.PRPCOW is not a constructor
Using CommonJS require() instead of ESM import.
fix
Change to 'import { PRPCOW } from 'prpcow'
Error: WebSocket is not defined
Missing ws package on Node.js server side.
fix
Install ws: 'npm install ws'
Error: Connection not established
Forgetting to call .connect() on the server-side PRPCOW instance after WebSocket connection.
fix
Call rpc.connect(ws) when a new WebSocket connection is established.
TypeError: client.call is not a function
Using PRPCOWClient incorrectly (missing 'new' or wrong import).
fix
Ensure correct import and instantiation: const client = new PRPCOWClient(ws);
Upgrade
Version history
2.0.0-alpha.23latest on npm
Audit
Dependencies
wsoptionalWebSocket implementation for Node.js; required as peer dependency for server-side use.
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
packageprpcow
prpcow — npm install prpcow · libregistry