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.

messaging
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 is a named export. Default import is incorrect.

import { Queue } from 'ws-socket-queue'

TypeScript type for message objects.

import { Message } from 'ws-socket-queue'

Package is ESM-only; CommonJS require may fail.

import { createQueue } from 'ws-socket-queue'

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 footguns
breakingIn version 1.2.0, the constructor options changed: 'wsUrl' renamed to 'url'.
deprecatedThe 'enqueue' method now uses a callback parameter instead of returning a Promise in v1.3.0.
gotchaQueue does not automatically connect; you must call .connect() after enqueuing messages, otherwise messages are held in memory.
gotchaMessage types are not validated at runtime; malformed messages may cause runtime errors.
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.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
11 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources