Skip to content

Commit

Permalink
Chore: Update ws package (#24477)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego authored Feb 14, 2022
1 parent 732bb4f commit beec51b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ee/server/services/ddp-streamer/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ export class Client extends EventEmitter {
this.timeout = setTimeout(this.handleIdle, timeout);
}

handler = async (payload: string): Promise<void> => {
handler = async (payload: WebSocket.Data, isBinary: boolean): Promise<void> => {
try {
const packet = server.parse(payload);
const packet = server.parse(payload, isBinary);
this.emit('message', packet);
if (this.wait) {
return new Promise((resolve) => this.once(DDP_EVENTS.LOGGED, () => resolve(this.process(packet.msg, packet))));
Expand Down
8 changes: 7 additions & 1 deletion ee/server/services/ddp-streamer/Server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EventEmitter } from 'events';

import type WebSocket from 'ws';
import ejson from 'ejson';
import { v1 as uuidv1 } from 'uuid';

Expand Down Expand Up @@ -42,7 +43,12 @@ export class Server extends EventEmitter {

serialize = ejson.stringify;

parse = (packet: string): IPacket => {
parse = (data: WebSocket.Data, isBinary: boolean): IPacket => {
if (isBinary) {
throw new MeteorError(500, 'Binary data not supported');
}
const packet = data.toString();

const payload = packet.startsWith('[') ? JSON.parse(packet)[0] : packet;
return ejson.parse(payload);
};
Expand Down
18 changes: 12 additions & 6 deletions ee/server/services/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"sodium-plus": "^0.9.0",
"underscore.string": "^3.3.6",
"uuid": "^7.0.3",
"ws": "^7.5.5"
"ws": "^8.5.0"
},
"devDependencies": {
"@types/cookie": "^0.4.1",
Expand All @@ -56,7 +56,7 @@
"@types/fibers": "^3.1.1",
"@types/mongodb": "^3.6.19",
"@types/node": "^14.17.4",
"@types/ws": "^7.4.7",
"@types/ws": "^8.2.2",
"pino-pretty": "^7.5.0",
"pm2": "^5.1.2",
"ts-node": "^10.5.0",
Expand Down

0 comments on commit beec51b

Please sign in to comment.