@wireapp/core 27.3.1 → 27.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [27.3.4](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.3...@wireapp/core@27.3.4) (2022-06-08)
7
+
8
+ **Note:** Version bump only for package @wireapp/core
9
+
10
+
11
+
12
+
13
+
14
+ ## [27.3.3](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.2...@wireapp/core@27.3.3) (2022-06-08)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **core:** Abort notification stream handling when websocket is disconnected ([#4285](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4285)) ([e674a38](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/e674a3827f4e107f9d6ef39e26fa8d94c58986d7))
20
+
21
+
22
+
23
+
24
+
25
+ ## [27.3.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.1...@wireapp/core@27.3.2) (2022-06-07)
26
+
27
+ **Note:** Version bump only for package @wireapp/core
28
+
29
+
30
+
31
+
32
+
6
33
  ## [27.3.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.3.0...@wireapp/core@27.3.1) (2022-06-03)
7
34
 
8
35
  **Note:** Version bump only for package @wireapp/core
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dependencies": {
6
6
  "@types/long": "4.0.1",
7
7
  "@types/node": "~14",
8
- "@wireapp/api-client": "19.4.0",
8
+ "@wireapp/api-client": "19.6.0",
9
9
  "@wireapp/cryptobox": "12.8.0",
10
10
  "bazinga64": "5.10.0",
11
11
  "hash.js": "1.1.7",
@@ -69,6 +69,6 @@
69
69
  "test:project": "yarn dist && yarn test",
70
70
  "test:node": "nyc jasmine --config=jasmine.json"
71
71
  },
72
- "version": "27.3.1",
73
- "gitHead": "c99307f4d8a8b5e2373b204dbca151415648042c"
72
+ "version": "27.3.4",
73
+ "gitHead": "d4ad56bf0f2ca6759b2e19742de7e26388905c56"
74
74
  }
@@ -328,13 +328,13 @@ class Account extends events_1.EventEmitter {
328
328
  this.apiClient.transport.ws.removeAllListeners(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE);
329
329
  this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE, notification => handleNotification(notification, conversation_1.PayloadBundleSource.WEBSOCKET));
330
330
  this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_STATE_CHANGE, onConnectionStateChanged);
331
- const onBeforeConnect = async () => {
331
+ const onBeforeConnect = async (abortHandler) => {
332
332
  // Lock websocket in order to buffer any message that arrives while we handle the notification stream
333
333
  this.apiClient.transport.ws.lock();
334
334
  await this.service.notification.handleNotificationStream(async (notification, source, progress) => {
335
335
  await handleNotification(notification, source);
336
336
  onNotificationStreamProgress(progress);
337
- }, onMissedNotifications);
337
+ }, onMissedNotifications, abortHandler);
338
338
  // We can now unlock the websocket and let the new messages being handled and decrypted
339
339
  this.apiClient.transport.ws.unlock();
340
340
  onConnected();
@@ -342,6 +342,8 @@ class Account extends events_1.EventEmitter {
342
342
  await this.apiClient.connect(onBeforeConnect);
343
343
  return () => {
344
344
  this.apiClient.disconnect();
345
+ this.apiClient.transport.ws.removeAllListeners(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE);
346
+ this.apiClient.transport.ws.removeListener(tcp_1.WebSocketClient.TOPIC.ON_STATE_CHANGE, onConnectionStateChanged);
345
347
  };
346
348
  }
347
349
  async initEngine(context) {
@@ -8,6 +8,7 @@ import { PayloadBundle, PayloadBundleSource } from '../conversation';
8
8
  import { NotificationError } from '../CoreError';
9
9
  import type { CryptographyService } from '../cryptography';
10
10
  import { GenericMessage } from '@wireapp/protocol-messaging';
11
+ import { AbortHandler } from '@wireapp/api-client/src/tcp';
11
12
  export declare type HandledEventPayload = {
12
13
  event: Events.BackendEvent;
13
14
  mappedEvent?: PayloadBundle;
@@ -42,7 +43,7 @@ export declare class NotificationService extends EventEmitter {
42
43
  getNotificationEventList(): Promise<Events.BackendEvent[]>;
43
44
  setLastEventDate(eventDate: Date): Promise<Date>;
44
45
  setLastNotificationId(lastNotification: Notification): Promise<string>;
45
- handleNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void): Promise<void>;
46
+ handleNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void, abortHandler: AbortHandler): Promise<void>;
46
47
  handleNotification(notification: Notification, source: PayloadBundleSource, dryRun?: boolean): AsyncGenerator<HandledEventPayload>;
47
48
  private cleanupPayloadBundle;
48
49
  private handleEvent;
@@ -118,12 +118,18 @@ class NotificationService extends events_1.EventEmitter {
118
118
  async setLastNotificationId(lastNotification) {
119
119
  return this.database.updateLastNotificationId(lastNotification);
120
120
  }
121
- async handleNotificationStream(notificationHandler, onMissedNotifications) {
121
+ async handleNotificationStream(notificationHandler, onMissedNotifications, abortHandler) {
122
122
  const { notifications, missedNotification } = await this.getAllNotifications();
123
123
  if (missedNotification) {
124
124
  onMissedNotifications(missedNotification);
125
125
  }
126
126
  for (const [index, notification] of notifications.entries()) {
127
+ if (abortHandler.isAborted()) {
128
+ /* Stop handling notifications if the websocket has been disconnected.
129
+ * Upon reconnecting we are going to restart handling the notification stream for where we left of
130
+ */
131
+ return;
132
+ }
127
133
  await notificationHandler(notification, conversation_1.PayloadBundleSource.NOTIFICATION_STREAM, {
128
134
  done: index + 1,
129
135
  total: notifications.length,