{"id":49771,"library":"ws-socket-queue","title":"ws-socket-queue","description":"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.","status":"active","version":"1.1.8","language":"javascript","source_language":"en","source_url":"https://github.com/KoveyMar/ws-socket-queue","tags":["javascript","websocket","notification","typescript"],"install":[{"cmd":"npm install ws-socket-queue","lang":"bash","label":"npm"},{"cmd":"yarn add ws-socket-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add ws-socket-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Queue is a named export. Default import is incorrect.","wrong":"import Queue from 'ws-socket-queue'","symbol":"Queue","correct":"import { Queue } from 'ws-socket-queue'"},{"note":"TypeScript type for message objects.","symbol":"Message","correct":"import { Message } from 'ws-socket-queue'"},{"note":"Package is ESM-only; CommonJS require may fail.","wrong":"const { createQueue } = require('ws-socket-queue')","symbol":"createQueue","correct":"import { createQueue } from 'ws-socket-queue'"}],"quickstart":{"code":"import { Queue } from 'ws-socket-queue';\n\nconst queue = new Queue({\n  wsUrl: 'wss://example.com/socket',\n  reconnect: true,\n  maxRetries: 5,\n  onMessage: (msg) => {\n    console.log('Received:', msg);\n  }\n});\n\nqueue.enqueue({ type: 'greeting', payload: 'Hello' });\nqueue.connect();","lang":"typescript","description":"Creates a WebSocket message queue, connects to a server, and enqueues a message."},"warnings":[{"fix":"Use 'url' instead of 'wsUrl' in constructor options.","message":"In version 1.2.0, the constructor options changed: 'wsUrl' renamed to 'url'.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Provide a callback function as second argument to enqueue.","message":"The 'enqueue' method now uses a callback parameter instead of returning a Promise in v1.3.0.","severity":"deprecated","affected_versions":">=1.3.0"},{"fix":"Always call connect() after enqueuing initial messages.","message":"Queue does not automatically connect; you must call .connect() after enqueuing messages, otherwise messages are held in memory.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use TypeScript or validate messages before enqueueing.","message":"Message types are not validated at runtime; malformed messages may cause runtime errors.","severity":"gotcha","affected_versions":">=1.0.0 <2.0.0"},{"fix":"Upgrade Node.js to 18+ or stay on v1.x for older Node.js.","message":"In version 2.0.0, the library was rewritten to use native WebSocket API instead of the 'ws' package, breaking Node.js versions below 18.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'1.1.8':21 'api':26 'applic':53 'browser':64 'current':17 'deliveri':57 'depend':45 'dequeu':29 'design':48 'enqueu':28 'environ':65 'extern':44 'javascript':66 'lightweight':41 'loss':38 'manag':9 'messag':6,13,33,37,56 'node.js':62 'notif':68 'order':35 'prevent':36 'process':31 'provid':23 'queu':11 'queue':4,7 'real':51 'real-tim':50 'reconnect':40 'reliabl':55 'requir':54 'simpl':25 'socket':3,12 'stabl':18 'support':16 'time':52 'typescript':15,69 'version':19 'websocket':5,32,59,67 'ws':2 'ws-socket-queu':1","created_at":"2026-06-07T17:03:31.150029+00:00","updated_at":"2026-06-07T17:03:31.150029+00:00","problems":[{"fix":"Ensure you call queue.connect() and wait for 'open' event before sending.","cause":"Queue not connected; socket is null.","error":"TypeError: Cannot read properties of undefined (reading 'send')"},{"fix":"Run 'npm install ws-socket-queue' and use import syntax.","cause":"Package not installed or ESM import used in CommonJS context.","error":"Module not found: Error: Can't resolve 'ws-socket-queue'"},{"fix":"Use import { Queue } from 'ws-socket-queue' instead of import Queue from 'ws-socket-queue'.","cause":"Default import used instead of named import.","error":"TypeError: queue.enqueue is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/KoveyMar/ws-socket-queue#readme","github":"https://github.com/KoveyMar/ws-socket-queue","docs":null,"changelog":null,"pypi":null,"npm":"ws-socket-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}