Registry / devops / vscode-ws-jsonrpc

vscode-ws-jsonrpc

JSON →
library3.5.0jsnpmunverified

Library for implementing communication between JSON-RPC client and server over WebSocket, part of the monaco-languageclient monorepo (TypeFox). Current stable version is 3.5.0. Released as part of monaco-languageclient, see its CHANGELOG for details. Key differentiators: tight integration with VSCode's JSON-RPC protocol, server-side forwarding, and usage in language server protocol (LSP) over WebSocket. Peer dependency on 'vscode-jsonrpc' for type definitions. Used by Monaco Editor and Theia for LSP over WebSocket.

npm install vscode-ws-jsonrpc
INSTALL
IMPORT
SIG · VSCODE-WS-JSONRPC
V
vscode-ws-jsonrpc
devopsjavascriptv3.5.0
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.

listen
import { listen } from 'vscode-ws-jsonrpc';
const { listen } = require('vscode-ws-jsonrpc');
ESM-only; CommonJS require is not supported. TypeScript types are included.
createWebSocketConnection
import { createWebSocketConnection } from 'vscode-ws-jsonrpc';
import { createWebSocketConnection } from 'vscode-ws-jsonrpc/server';
This function is exported from the main entry, not from the /server subpath.
IWebSocket
import { IWebSocket } from 'vscode-ws-jsonrpc';
import { IWebSocket } from 'ws';
IWebSocket is an interface defined by the library, not the 'ws' Node.js package.

Creates a WebSocket connection, registers a notification handler, and sends a notification.

import { createWebSocketConnection, ConsoleLogger, IWebSocket } from 'vscode-ws-jsonrpc'; import { NotificationType } from 'vscode-languageserver'; const socket: IWebSocket = { send: (data) => {}, close: () => {} }; // dummy socket const logger = new ConsoleLogger(); const connection = createWebSocketConnection(socket, logger); const notification = new NotificationType<string, void>('testNotification'); connection.onNotification(notification, (param: string) => { console.log(param); }); connection.listen(); connection.sendNotification(notification, 'Hello World');
Debug
Known issues
breakingvscode-ws-jsonrpc 3.x dropped support for Node.js versions <20.10.0.
fix
Upgrade Node.js to >=20.10.0.
affects: >=3.0.0
breakingThe package is now ESM-only since version 3.0.0. CommonJS require will fail.
fix
Use ES modules (import) in your project. If you must use CommonJS, consider dynamic import or downgrade to 2.x.
affects: >=3.0.0
deprecatedThe 'server' subpath import (e.g., from 'vscode-ws-jsonrpc/server') may be removed in future versions. Functions like createServerProcess are now available from the main entry.
fix
Import from the main entry: import { createServerProcess, forward } from 'vscode-ws-jsonrpc';
affects: >=3.0.0
gotchaThe 'listen' function expects a 'webSocket' property (WebSocket) - not the raw socket object. Use IWebSocket for other usages.
fix
When using 'listen', pass an object with a 'webSocket' key: { webSocket: myWebSocket, onConnection: ... }.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'vscode-ws-jsonrpc' or its corresponding type declarations.
Package not installed or TypeScript cannot locate types.
fix
Install the package: npm install vscode-ws-jsonrpc. Ensure tsconfig.json includes 'node_modules' in typeRoots or use 'skipLibCheck': true.
ERR_REQUIRE_ESM: require() of ES Module /node_modules/vscode-ws-jsonrpc/lib/index.js from ... not supported.
Using CommonJS require() on an ESM-only package.
fix
Switch to ES modules by setting "type": "module" in package.json and using import statements, or downgrade to v2.x.
TypeError: connection.sendNotification is not a function
Calling sendNotification before connection.listen() has been called.
fix
Ensure you call connection.listen() before sending any messages.
Upgrade
Version history
3.5.0latest on npm
Audit
Dependencies
vscode-jsonrpcrequiredProvides MessageConnection, NotificationType, and other core JSON-RPC types used by vscode-ws-jsonrpc's public API (e.g., listen function).
Agent activity
8 hits · last 30 days
node
8
Resources
vscode-ws-jsonrpc — npm install vscode-ws-jsonrpc · libregistry