Registry / messaging / ws-socket-queue

ws-socket-queue

JSON →
library1.1.8jsnpmunverified

WebSocket message queue for managing and queuing socket messages with TypeScript support. Current stable version is 1.1.8. It provides a simple API to enqueue, dequeue, and process WebSocket messages in order, preventing message loss during reconnection. Lightweight with no external dependencies, it is designed for real-time applications requiring reliable message delivery over WebSockets in both Node.js and browser environments.

npm install ws-socket-queue
INSTALL
IMPORT
SIG · WS-SOCKET-QUEUE
W
ws-socket-queue
messagingjavascriptv1.1.8
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.

Queue
import { Queue } from 'ws-socket-queue'
import Queue from 'ws-socket-queue'
Queue is a named export. Default import is incorrect.
Message
import { Message } from 'ws-socket-queue'
TypeScript type for message objects.
createQueue
import { createQueue } from 'ws-socket-queue'
const { createQueue } = require('ws-socket-queue')
Package is ESM-only; CommonJS require may fail.

Creates a WebSocket message queue, connects to a server, and enqueues a message.

import { Queue } from 'ws-socket-queue'; const queue = new Queue({ wsUrl: 'wss://example.com/socket', reconnect: true, maxRetries: 5, onMessage: (msg) => { console.log('Received:', msg); } }); queue.enqueue({ type: 'greeting', payload: 'Hello' }); queue.connect();
Debug
Known issues
breakingIn version 1.2.0, the constructor options changed: 'wsUrl' renamed to 'url'.
fix
Use 'url' instead of 'wsUrl' in constructor options.
affects: >=1.2.0
deprecatedThe 'enqueue' method now uses a callback parameter instead of returning a Promise in v1.3.0.
fix
Provide a callback function as second argument to enqueue.
affects: >=1.3.0
gotchaQueue does not automatically connect; you must call .connect() after enqueuing messages, otherwise messages are held in memory.
fix
Always call connect() after enqueuing initial messages.
affects: >=1.0.0
gotchaMessage types are not validated at runtime; malformed messages may cause runtime errors.
fix
Use TypeScript or validate messages before enqueueing.
affects: >=1.0.0 <2.0.0
breakingIn version 2.0.0, the library was rewritten to use native WebSocket API instead of the 'ws' package, breaking Node.js versions below 18.
fix
Upgrade Node.js to 18+ or stay on v1.x for older Node.js.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'send')
Queue not connected; socket is null.
fix
Ensure you call queue.connect() and wait for 'open' event before sending.
Module not found: Error: Can't resolve 'ws-socket-queue'
Package not installed or ESM import used in CommonJS context.
fix
Run 'npm install ws-socket-queue' and use import syntax.
TypeError: queue.enqueue is not a function
Default import used instead of named import.
fix
Use import { Queue } from 'ws-socket-queue' instead of import Queue from 'ws-socket-queue'.
Upgrade
Version history
1.1.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
31
Amazon
1
OpenAI (training)
1
Resources