Registry / messaging / pull-ws

pull-ws

JSON →
library3.3.2jsnpmunverified

Version 3.3.2 (latest). Provides a pull-stream interface for WebSocket client and server connections. Supports both Node.js and browser environments (via ws package on Node). Key differentiators: uses pull-streams (not Node streams), offers simple connect/server APIs, and integrates well with multiplexing libraries like muxrpc. Stable but marked as unstable by author; maintained with occasional updates.

npm install pull-ws
INSTALL
IMPORT
SIG · PULL-WS
P
pull-ws
messagingjavascriptv3.3.2
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.

connect
const connect = require('pull-ws/client')
import { connect } from 'pull-ws/client'
ESM import may not work; package is CJS. Use require() or use default import if using bundler.
createServer
const createServer = require('pull-ws/server')
const createServer = require('pull-ws').createServer
Exposed only as separate submodules, not as a property of the main module.
duplex
const duplex = require('pull-ws/duplex')
const duplex = require('pull-ws').duplex
Rarely used directly; for wrapping a raw WebSocket.

Shows connecting to a WebSocket echo server, sending two messages, and collecting responses via pull-stream.

const pull = require('pull-stream') const connect = require('pull-ws/client') const sink = pull.collect((err, results) => { if (err) throw err console.log(results) }) connect('ws://echo.websocket.org', { binary: false, onConnect: (err, stream) => { if (err) throw err pull(pull.values(['hello', 'world']), stream, sink) }})
Debug
Known issues
gotchaDefault binary behavior differs between Node and browser: on Node defaults to true (arrayBuffers), on browser defaults to false (strings). This can cause type mismatches if assumptions differ.
fix
Explicitly set binary: true or false in connect options to ensure consistent behavior.
affects: >=1.0.0 <4.0.0
gotchaWebSocket connections may fail silently if errors are not handled. If no callback is provided to connect(), the error is emitted as the first read from the stream.
fix
Always provide a callback to connect() to catch connection errors.
affects: >=1.0.0
deprecatedPackage stability is marked as 'unstable' by the author; API may change without major version bump.
fix
Pin to a specific version or monitor for breaking changes.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: pull_ws_client is not a function
Using ESM import (import ... from) on a CJS module without default interop.
fix
Use require('pull-ws/client') or configure bundler to handle CJS default exports.
Error: connect ECONNREFUSED
WebSocket server is not running or unreachable.
fix
Ensure server is running and URL is correct. Use onConnect callback to handle errors.
Uncaught (in promise) Error: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.
Sending non-binary data when stream expects binary (or vice versa).
fix
Set binary option consistently between client and server, and ensure data types match.
Upgrade
Version history
3.3.2latest on npm
Audit
Dependencies
pull-streamoptionalRequired to use the pull-stream pipeline with pull-ws streams
wsoptionalWebSocket implementation used on Node.js (not needed in browsers)
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
pull-ws — npm install pull-ws · libregistry