{"id":47357,"library":"cy-plugin-websocket","title":"cy-plugin-websocket","description":"A WebSocket client wrapper library with auto-reconnect (exponential backoff), heartbeat mechanism, message queue, and Emittery-based event system. Version 2.0.5, stable with monthly releases. Key differentiators: full TypeScript support, enum-based event names for type safety, configurable heartbeat and reconnect strategies, and built-in message buffering during disconnection. Requires peer dependency Emittery ^1.2.0.","status":"active","version":"2.0.5","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","utils","js","typescript"],"install":[{"cmd":"npm install cy-plugin-websocket","lang":"bash","label":"npm"},{"cmd":"yarn add cy-plugin-websocket","lang":"bash","label":"yarn"},{"cmd":"pnpm add cy-plugin-websocket","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Event system dependency; must be installed separately as a peer dependency","package":"emittery","optional":false}],"imports":[{"note":"Both SocketClient and enumSocketEvent are named exports. Default export does not exist.","wrong":"import SocketClient from 'cy-plugin-websocket'","symbol":"SocketClient","correct":"import { SocketClient, enumSocketEvent } from 'cy-plugin-websocket'"},{"note":"Exact name is 'enumSocketEvent' (camelCase). Incorrect casing leads to undefined.","wrong":"import { EnumSocketEvent } from 'cy-plugin-websocket'","symbol":"enumSocketEvent","correct":"import { enumSocketEvent } from 'cy-plugin-websocket'"},{"note":"ISocketOption is a TypeScript interface, should be imported as type for better tree-shaking.","wrong":"import { ISocketOption } from 'cy-plugin-websocket'","symbol":"ISocketOption","correct":"import type { ISocketOption } from 'cy-plugin-websocket'"}],"quickstart":{"code":"import { SocketClient, enumSocketEvent } from 'cy-plugin-websocket';\n\nconst socket = new SocketClient('wss://example.com/ws', {\n  debug: true,\n  connectResend: true,\n  heartOption: { message: { type: 'ping' }, interval: 30000 },\n  reconnectOption: { maxCount: 5, interval: 2000, maxInterval: 10000 }\n});\n\nsocket.connect();\n\nsocket.on(enumSocketEvent.OPEN, () => console.log('Connected'));\nsocket.on(enumSocketEvent.MESSAGE, (data) => console.log('Message:', data));\nsocket.on(enumSocketEvent.ERROR, (err) => console.error('Error:', err));\n\nsocket.send({ type: 'chat', message: 'Hello World' });\n\n// Later\nsocket.close();","lang":"typescript","description":"Shows creation of SocketClient with advanced config, connection, event handling using enumSocketEvent, sending a message, and closing the connection."},"warnings":[{"fix":"Use named import: import { SocketClient } from 'cy-plugin-websocket'","message":"Importing SocketClient as default export fails in versions >=2.0.0","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use enumSocketEvent.OPEN instead of 'open' for type safety and compatibility","message":"Event names must use enumSocketEvent enum, not raw strings","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use enumSocketEvent for event names","message":"Method 'on' with string event name is deprecated since 2.0.0","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Install emittery@1.2.0 as a dependency: npm install emittery@1.2.0 --save","message":"Heavy reliance on Emittery peer dependency; missing Emittery causes runtime error","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"No extra @types package needed; types are included in the package","message":"TypeScript types are exported but not on DefinitelyTyped; use built-in types","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'1.2.0':62 '2.0.5':27 'auto':12 'auto-reconnect':11 'backoff':15 'base':23,39 'buffer':55 'built':52 'built-in':51 'client':7 'configur':45 'cy':2 'cy-plugin-websocket':1 'depend':60 'differenti':33 'disconnect':57 'emitteri':22,61 'emittery-bas':21 'enum':38 'enum-bas':37 'event':24,40 'exponenti':14 'full':34 'heartbeat':16,46 'javascript':63 'js':65 'key':32 'librari':9 'mechan':17 'messag':18,54 'month':30 'name':41 'peer':59 'plugin':3 'queue':19 'reconnect':13,48 'releas':31 'requir':58 'safeti':44 'stabl':28 'strategi':49 'support':36 'system':25 'type':43 'typescript':35,66 'util':64 'version':26 'websocket':4,6 'wrapper':8","created_at":"2026-06-07T16:51:07.263861+00:00","updated_at":"2026-06-07T16:51:07.263861+00:00","problems":[{"fix":"Install emittery@1.2.0: npm install emittery@1.2.0","cause":"Missing or incompatible Emittery peer dependency","error":"TypeError: emmiter.on is not a function"},{"fix":"Use named import: import { SocketClient } from 'cy-plugin-websocket'","cause":"Using default import when only named export exists","error":"Module '\"cy-plugin-websocket\"' has no exported member 'SocketClient'"},{"fix":"Install package: npm install cy-plugin-websocket; ensure tsconfig.json includes node module resolution","cause":"Package not installed or TypeScript not resolving types correctly","error":"Cannot find module 'cy-plugin-websocket' or its corresponding type declarations."},{"fix":"Call socket.connect() before adding event listeners","cause":"Attempting to use 'on' before calling connect()","error":"Uncaught TypeError: socket.on 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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"cy-plugin-websocket","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}}