Skip to content

Commit

Permalink
chore(websocket): bump dependencies (#17325)
Browse files Browse the repository at this point in the history
* chore(websocket): bump dependencies

* bump client-ws-app

* bump more packages
  • Loading branch information
villebro authored Nov 3, 2021
1 parent 2199ef2 commit 33bcf82
Show file tree
Hide file tree
Showing 10 changed files with 3,806 additions and 6,897 deletions.
8,654 changes: 2,650 additions & 6,004 deletions superset-websocket/package-lock.json

Large diffs are not rendered by default.

34 changes: 19 additions & 15 deletions superset-websocket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,33 @@
"license": "Apache-2.0",
"dependencies": {
"cookie": "^0.4.1",
"hot-shots": "^8.3.1",
"ioredis": "^4.16.1",
"hot-shots": "^9.0.0",
"ioredis": "^4.28.0",
"jsonwebtoken": "^8.5.1",
"uuid": "^8.3.2",
"winston": "^3.3.3",
"ws": "^7.4.2"
"ws": "^8.2.3"
},
"devDependencies": {
"@types/cookie": "^0.4.0",
"@types/ioredis": "^4.22.0",
"@types/jest": "^26.0.20",
"@types/jsonwebtoken": "^8.5.1",
"@types/node": "^14.14.22",
"@types/uuid": "^8.3.0",
"@types/ws": "^7.4.0",
"@types/cookie": "^0.4.1",
"@types/ioredis": "^4.27.8",
"@types/jest": "^27.0.2",
"@types/jsonwebtoken": "^8.5.5",
"@types/node": "^16.11.6",
"@types/uuid": "^8.3.1",
"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"jest": "^26.6.3",
"prettier": "2.2.1",
"ts-jest": "^26.5.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^7.1.0",
"jest": "^27.3.1",
"prettier": "^2.4.1",
"ts-jest": "^27.0.7",
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
},
"engines": {
"node": "^16.9.1",
"npm": "^7.5.4"
}
}
30 changes: 21 additions & 9 deletions superset-websocket/spec/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const config = require('../config.test.json');
import { describe, expect, test, beforeEach, afterEach } from '@jest/globals';
import * as http from 'http';
import * as net from 'net';
import WebSocket from 'ws';
import { WebSocket } from 'ws';

// NOTE: these mock variables needs to start with "mock" due to
// calls to `jest.mock` being hoisted to the top of the file.
Expand Down Expand Up @@ -459,6 +459,18 @@ describe('server', () => {
});
});

const setReadyState = (ws: WebSocket, value: typeof ws.readyState) => {
// workaround for not being able to do
// spyOn(instance,'readyState','get').and.returnValue(value);
// See for details: https://github.com/facebook/jest/issues/9675
Object.defineProperty(ws, 'readyState', {
configurable: true,
get() {
return value;
},
});
};

describe('checkSockets', () => {
let ws: WebSocket;
let pingSpy: jest.SpyInstance;
Expand All @@ -473,7 +485,7 @@ describe('server', () => {
});

test('active sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
server.trackClient(channelId, socketInstance);

server.checkSockets();
Expand All @@ -484,7 +496,7 @@ describe('server', () => {
});

test('stale sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
socketInstance.pongTs = Date.now() - 60000;
server.trackClient(channelId, socketInstance);

Expand All @@ -496,7 +508,7 @@ describe('server', () => {
});

test('closed sockets', () => {
ws.readyState = WebSocket.CLOSED;
setReadyState(ws, WebSocket.CLOSED);
server.trackClient(channelId, socketInstance);

server.checkSockets();
Expand All @@ -522,7 +534,7 @@ describe('server', () => {
});

test('active sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
server.trackClient(channelId, socketInstance);

server.cleanChannel(channelId);
Expand All @@ -531,7 +543,7 @@ describe('server', () => {
});

test('closing sockets', () => {
ws.readyState = WebSocket.CLOSING;
setReadyState(ws, WebSocket.CLOSING);
server.trackClient(channelId, socketInstance);

server.cleanChannel(channelId);
Expand All @@ -540,11 +552,11 @@ describe('server', () => {
});

test('multiple sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
server.trackClient(channelId, socketInstance);

const ws2 = new wsMock('localhost');
ws2.readyState = WebSocket.OPEN;
setReadyState(ws2, WebSocket.OPEN);
const socketInstance2 = {
ws: ws2,
channel: channelId,
Expand All @@ -556,7 +568,7 @@ describe('server', () => {

expect(server.channels[channelId].sockets.length).toBe(2);

ws2.readyState = WebSocket.CLOSED;
setReadyState(ws2, WebSocket.CLOSED);
server.cleanChannel(channelId);

expect(server.channels[channelId].sockets.length).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion superset-websocket/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const wss = new WebSocket.Server({
clientTracking: false,
});

const SOCKET_ACTIVE_STATES = [WebSocket.OPEN, WebSocket.CONNECTING];
const SOCKET_ACTIVE_STATES: number[] = [WebSocket.OPEN, WebSocket.CONNECTING];
const GLOBAL_EVENT_STREAM_NAME = `${opts.redisStreamPrefix}full`;
const DEFAULT_STREAM_LAST_ID = '$';

Expand Down
2 changes: 1 addition & 1 deletion superset-websocket/utils/client-ws-app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.set('view engine', 'pug');

app.use(logger('dev'));
app.use(express.json());
Expand Down
Loading

0 comments on commit 33bcf82

Please sign in to comment.