Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
chore: Upgrade to ws v8.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Jan 28, 2022
1 parent c924ad4 commit 58b522a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -3,14 +3,14 @@
"url": "https://github.com/bennycode/coinbase-pro-node/issues"
},
"dependencies": {
"@types/ws": "7.4.7",
"@types/ws": "8.2.2",
"axios": "0.25.0",
"axios-retry": "3.2.4",
"buffer": "6.0.3",
"bufferutil": "4.0.6",
"reconnecting-websocket": "4.4.0",
"utf-8-validate": "5.0.8",
"ws": "7.5.6"
"ws": "8.4.2"
},
"description": "Coinbase Pro API for Node.js, written in TypeScript and covered by tests.",
"devDependencies": {
Expand Down
19 changes: 13 additions & 6 deletions src/client/WebSocketClient.test.ts
Expand Up @@ -126,7 +126,10 @@ describe('WebSocketClient', () => {
describe('constructor', () => {
it('it signals an event when the WebSocket connection is established', done => {
const ws = createWebSocketClient();
ws.on(WebSocketEvent.ON_OPEN, () => done());
ws.on(WebSocketEvent.ON_OPEN, async () => {
await ws.disconnect();
done();
});
ws.connect();
});
});
Expand Down Expand Up @@ -429,8 +432,9 @@ describe('WebSocketClient', () => {

const ws = createWebSocketClient();

ws.on(WebSocketEvent.ON_MESSAGE_ERROR, errorMessage => {
ws.on(WebSocketEvent.ON_MESSAGE_ERROR, async errorMessage => {
expect(errorMessage.type).toBe(WebSocketResponseType.ERROR);
await ws.disconnect();
done();
});

Expand Down Expand Up @@ -483,13 +487,15 @@ describe('WebSocketClient', () => {

const ws = createWebSocketClient();

ws.on(WebSocketEvent.ON_SUBSCRIPTION_UPDATE, subscriptions => {
ws.on(WebSocketEvent.ON_SUBSCRIPTION_UPDATE, async subscriptions => {
if (subscriptions.channels.length === 0) {
ws.disconnect();
await ws.disconnect();
}
});

ws.on(WebSocketEvent.ON_CLOSE, done);
ws.on(WebSocketEvent.ON_CLOSE, () => {
done();
});

ws.on(WebSocketEvent.ON_OPEN, () => ws.unsubscribe(WebSocketChannelName.TICKER));

Expand All @@ -500,7 +506,8 @@ describe('WebSocketClient', () => {
describe('setupHeartbeat', () => {
it('sends ping messages within a defined interval', done => {
server.on('connection', socket => {
socket.on('ping', () => {
socket.on('ping', async () => {
await ws.disconnect();
done();
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/client/WebSocketClient.ts
Expand Up @@ -531,7 +531,7 @@ export class WebSocketClient extends EventEmitter {
}

/**
* Enforce a reconnect when not receiving any 'pong' from Coinbase Pro in time.
* Enforce reconnect when not receiving any 'pong' from Coinbase Pro in time.
* @see https://github.com/bennycode/coinbase-pro-node/issues/374
*/
this.pongTimeout = setTimeout(this.onPongTimeout.bind(this), this.pongTime);
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Expand Up @@ -318,10 +318,10 @@
resolved "https://registry.npmjs.org/@types/node/-/node-15.12.2.tgz#1f2b42c4be7156ff4a6f914b2fb03d05fa84e38d"
integrity sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww==

"@types/ws@7.4.7":
version "7.4.7"
resolved "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702"
integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==
"@types/ws@8.2.2":
version "8.2.2"
resolved "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz#7c5be4decb19500ae6b3d563043cd407bf366c21"
integrity sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==
dependencies:
"@types/node" "*"

Expand Down Expand Up @@ -2518,10 +2518,10 @@ write-file-atomic@^3.0.0:
signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5"

ws@7.5.6:
version "7.5.6"
resolved "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz#e59fc509fb15ddfb65487ee9765c5a51dec5fe7b"
integrity sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==
ws@8.4.2:
version "8.4.2"
resolved "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz#18e749868d8439f2268368829042894b6907aa0b"
integrity sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==

y18n@^4.0.0:
version "4.0.3"
Expand Down

0 comments on commit 58b522a

Please sign in to comment.