From 0467c410c85b74586c3ce2b82352379c92a9406d Mon Sep 17 00:00:00 2001 From: Valentin Fernandez <33705477+valentinfernandez1@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:41:53 -0300 Subject: [PATCH] Rollback ws change on x-ws (#1980) --- packages/x-ws/src/node.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/x-ws/src/node.ts b/packages/x-ws/src/node.ts index 8138aa837..3fffe8065 100644 --- a/packages/x-ws/src/node.ts +++ b/packages/x-ws/src/node.ts @@ -7,16 +7,4 @@ import { extractGlobal } from '@polkadot/x-global'; export { packageInfo } from './packageInfo.js'; -/** - * The built-in `globalThis.WebSocket` in Node.js 22+ does not provide - * detailed error messages (e.g., `ECONNREFUSED` or `ETIMEDOUT`), making - * it difficult to implement proper reconnection logic. - * - * To avoid these issues, we explicitly use the `ws` library in Node.js 22+ - * while still preserving support for the browser WebSocket API in browser environments. - * - * Related Issue: https://github.com/polkadot-js/common/issues/1975 - */ -const isNode22 = typeof process !== 'undefined' && parseInt(process.versions?.node?.split('.')[0] || '0', 10) >= 22; - -export const WebSocket = isNode22 ? (ws as unknown as typeof globalThis.WebSocket) : /*#__PURE__*/ extractGlobal('WebSocket', ws); +export const WebSocket = /*#__PURE__*/ extractGlobal('WebSocket', ws);