Skip to content

Commit

Permalink
noobaa/core: remove global websocket
Browse files Browse the repository at this point in the history
In node v22, websocket is enabled by default
nodejs/node#51594

This will cause an error on following line when the global.Websocket
would be true.
const WS = global.WebSocket || require('ws');

global.WebSocket: This will points to Node.js's native WebSocket,
which does not include a Server class.
require('ws'): The ws package includes both WebSocket and
WebSocket.Server, but this fallback is skipped because global.WebSocket
is already defined in Node.js v22

Signed-off-by: Ashish Pandey <aspandey@redhat.com>
  • Loading branch information
aspandey committed Nov 10, 2024
1 parent c436cb6 commit ee6cf99
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rpc/rpc_ws.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (C) 2016 NooBaa */
'use strict';

const WS = global.WebSocket || require('ws');
const WS = require('ws');

const dbg = require('../util/debug_module')(__filename);
const http_utils = require('../util/http_utils');
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rpc_ws_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const url = require('url');
const EventEmitter = require('events').EventEmitter;
const RpcWsConnection = require('./rpc_ws');
const dbg = require('../util/debug_module')(__filename);
const WS = global.WebSocket || require('ws');
const WS = require('ws');


/**
Expand Down

0 comments on commit ee6cf99

Please sign in to comment.